Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const DEFAULT_PLAYWRIGHT_CHANNEL = 'chromium';
const DEFAULT_PLAYWRIGHT_ARGS = ['--enable-unsafe-webgpu', '--ignore-gpu-blocklist'];
const DEFAULT_PLAYWRIGHT_ARGS = [
'--disable-dev-shm-usage',
'--enable-unsafe-webgpu',
'--ignore-gpu-blocklist'
];
const SOFTWARE_GPU_ARGS = ['--use-angle=swiftshader', '--enable-unsafe-swiftshader'];

export function getPlaywrightLaunchOptions(options = {}) {
Expand Down
50 changes: 44 additions & 6 deletions modules/mvt/test/mvt-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,25 @@ test('MVTLoader#Parse Polygons MVT', async t => {
};

const geometry = await parse(mvtArrayBuffer, MVTLoader, loaderOptions);
let expected = binary
? decodedPolygonsGeoJSON
: {shape: 'geojson-table', type: 'FeatureCollection', features: decodedPolygonsGeoJSON};
if (binary) {
// @ts-ignore
expected = geojsonToBinary(expected, {fixRingWinding: false});
const expected = geojsonToBinary(structuredClone(decodedPolygonsGeoJSON), {
fixRingWinding: false
});
t.ok(geometry.byteLength > 0);
delete geometry.byteLength;
t.deepEqual(geometry, expected, `Parsed Polygons MVT as ${outputFormat}`);
} else {
const expected = {
shape: 'geojson-table',
type: 'FeatureCollection',
features: normalizeGeoJsonFeatures(decodedPolygonsGeoJSON)
};
const normalizedGeometry = {
...geometry,
features: normalizeGeoJsonFeatures(geometry.features)
};
t.deepEqual(normalizedGeometry, expected, `Parsed Polygons MVT as ${outputFormat}`);
}
t.deepEqual(geometry, expected, `Parsed Polygons MVT as ${outputFormat}`);
}
t.end();
});
Expand Down Expand Up @@ -368,3 +377,32 @@ test('Triangulation is supported', async t => {

t.end();
});

/**
* Copies GeoJSON features while normalizing projected coordinate precision for stable comparisons.
*
* @param features GeoJSON features to normalize.
* @returns Feature copies with rounded geometry coordinates.
*/
function normalizeGeoJsonFeatures(features: any[]): any[] {
return features.map(feature => ({
...feature,
geometry: {
...feature.geometry,
coordinates: roundCoordinates(feature.geometry.coordinates)
}
}));
}

/**
* Rounds nested coordinates to avoid browser-specific floating-point projection drift.
*
* @param coordinates Nested GeoJSON coordinate values.
* @returns Coordinates rounded to stable sub-millimeter precision.
*/
function roundCoordinates(coordinates: any): any {
if (Array.isArray(coordinates)) {
return coordinates.map(value => roundCoordinates(value));
}
return typeof coordinates === 'number' ? Number(coordinates.toFixed(9)) : coordinates;
}
Loading