Mapbox vector layer

This commit is contained in:
Tim Schaub
2020-05-03 14:15:14 -06:00
parent fcc9163494
commit 4d9975754f
20 changed files with 4642 additions and 33 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@@ -0,0 +1,22 @@
import Map from '../../../src/ol/Map.js';
import MapboxVector from '../../../src/ol/layer/MapboxVector.js';
import View from '../../../src/ol/View.js';
new Map({
layers: [
new MapboxVector({
styleUrl: '/data/styles/bright-v9.json',
accessToken: 'test-token',
}),
],
target: 'map',
view: new View({
center: [1825927.7316762917, 6143091.089223046],
zoom: 15,
}),
});
render({
message: 'Mapbox vector layer renders',
tolerance: 0.025,
});

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,12 @@ To run a single rendering test case:
node rendering/test.js --match your-test-case-name
```
If you want to leave the test server running (and the test browser open) after running a test, use the `--interactive` option.
```bash
node rendering/test.js --match your-test-case-name --interactive
```
## Creating a new test
To create a new test case, add a directory under `cases` and add a `main.js` to it (copied from one of the other cases). Then to generate the `expected.png` screenshot, run the test script with the `--fix` flag:

View File

@@ -251,7 +251,7 @@ async function render(entries, options) {
page.on('console', (message) => {
const type = message.type();
if (options.log[type]) {
options.log[type](message.text());
options.log[type](`console: ${message.text()}`);
}
});
@@ -260,6 +260,10 @@ async function render(entries, options) {
await page.setViewport({width: 256, height: 256});
fail = await renderEach(page, entries, options);
} finally {
if (options.interactive) {
options.log.info('🐛 you have thirty minutes to debug, go!');
await sleep(30 * 60 * 1000);
}
browser.close();
}
@@ -324,12 +328,16 @@ async function main(entries, options) {
try {
await render(entries, options);
} finally {
if (!options.interactive) {
done();
}
done();
}
}
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
if (require.main === module) {
const options = yargs
.option('fix', {
@@ -356,8 +364,7 @@ if (require.main === module) {
default: false,
})
.option('interactive', {
describe:
'Run all tests and keep the test server running (this option will be reworked later)',
describe: 'Run all tests and keep the test server running for 30 minutes',
type: 'boolean',
default: false,
})

View File

@@ -34,4 +34,10 @@ module.exports = {
},
],
},
resolve: {
alias: {
// allow imports from 'ol/module' instead of specifiying the source path
ol: path.join(__dirname, '..', 'src', 'ol'),
},
},
};