Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some updates from review #252

Merged
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
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const outputFile =
minified ? 'dist/maplibre-gl.js' : 'dist/maplibre-gl-unminified.js';

export default [{
// Before rollup you should run build-tsc to transpile from typesript to javascript
// and to copy the shaders and convert them to js strings
// Before rollup you should run build-tsc to transpile from typescript to javascript
// and to copy the shaders and convert them to js strings
// Rollup will use code splitting to bundle GL JS into three "chunks":
// - rollup/build/maplibregl/index.js: the main module, plus all its dependencies not shared by the worker module
// - rollup/build/maplibregl/worker.js: the worker module, plus all dependencies not shared by the main module
Expand Down
8 changes: 2 additions & 6 deletions rollup.config.style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import unassert from 'rollup-plugin-unassert';
import json from '@rollup/plugin-json';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));
import {fileURLToPath} from 'url';

const esm = 'esm' in process.env;

const ROOT_DIR = __dirname;

const config = [{
input: 'rollup/build/tsc/style-spec/style-spec.js',
output: {
Expand All @@ -29,7 +25,7 @@ const config = [{
// This check will cause the build to fail on CI allowing these issues to be caught.
if (importer && !importer.includes('node_modules')) {
const resolvedPath = path.join(importer, source);
const fromRoot = path.relative(ROOT_DIR, resolvedPath);
const fromRoot = path.relative(dirname(fileURLToPath(import.meta.url)), resolvedPath);
if (fromRoot.length > 2 && fromRoot.slice(0, 2) === '..') {
throw new Error(`Module ${importer} imports ${source} from outside the style-spec package root directory.`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export function deserialize(input: Array<Bucket>, style: Style): {[_: string]: B
// 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 as any).stateDependentLayerIds) {
(bucket as any).stateDependentLayers = (bucket as any).stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);
if (bucket.stateDependentLayerIds) {
(bucket as any).stateDependentLayers = bucket.stateDependentLayerIds.map((lId) => layers.filter((l) => l.id === lId)[0]);
wipfli marked this conversation as resolved.
Show resolved Hide resolved
}
for (const layer of layers) {
output[layer.id] = bucket;
Expand Down
4 changes: 1 addition & 3 deletions src/data/bucket/fill_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ class FillBucket implements Bucket {
}

if (sortFeaturesByKey) {
bucketFeatures.sort((a, b) => {
return (a.sortKey) - (b.sortKey);
});
bucketFeatures.sort((a, b) => a.sortKey - b.sortKey);
}

for (const bucketFeature of bucketFeatures) {
Expand Down
36 changes: 28 additions & 8 deletions src/data/bucket/symbol_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export type SymbolFeature = {
sourceLayerIndex: number,
geometry: Array<Array<Point>>,
properties: any,
type: "Point" | "LineString" | "Polygon",
type: 'Point' | 'LineString' | 'Polygon',
wipfli marked this conversation as resolved.
Show resolved Hide resolved
id?: any
};

Expand All @@ -107,7 +107,21 @@ const shaderOpacityAttributes = [
{name: 'a_fade_opacity', components: 1, type: 'Uint8' as ViewType, offset: 0}
];

function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex, isSDF: boolean, pixelOffsetX, pixelOffsetY, minFontScaleX, minFontScaleY) {
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
) {
wipfli marked this conversation as resolved.
Show resolved Hide resolved
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(
Expand Down Expand Up @@ -615,7 +629,7 @@ class SymbolBucket implements Bucket {
lineOffset: [number, number],
alongLine: boolean,
feature: SymbolFeature,
writingMode: any,
writingMode: WritingMode,
labelAnchor: Anchor,
lineStartIndex: number,
lineLength: number,
Expand Down Expand Up @@ -657,15 +671,21 @@ class SymbolBucket implements Bucket {
}
}

arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y,
glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex,
lineStartIndex, lineLength, ((labelAnchor.segment as any)),
sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0,
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 any),
false as unknown as number,
wipfli marked this conversation as resolved.
Show resolved Hide resolved
// The crossTileID is only filled/used on the foreground for dynamic text anchors
0,
associatedIconIndex
Expand Down
2 changes: 1 addition & 1 deletion src/data/feature_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FeatureIndex {
grid: Grid;
grid3D: Grid;
featureIndexArray: FeatureIndexArray;
promoteId: PromoteIdSpecification | undefined | null;
promoteId?: PromoteIdSpecification;
wipfli marked this conversation as resolved.
Show resolved Hide resolved

rawTileData: ArrayBuffer;
bucketLayerIDs: Array<Array<string>>;
Expand Down
1 change: 0 additions & 1 deletion src/geo/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ class Transform {
}

customLayerMatrix(): mat4 {
// I assume the previous 'slice' was just to trigger a copy?
return mat4.clone(this.mercatorMatrix);
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLa

const pattern = layer.paint.get('fill-pattern');
const pass = painter.opaquePassEnabledForLayer() &&
(!pattern.constantOr(((1 as any))) &&
(!pattern.constantOr(1 as any) &&
color.constantOr(Color.transparent).a === 1 &&
opacity.constantOr(0) === 1) ? 'opaque' : 'translucent';

Expand Down
6 changes: 2 additions & 4 deletions test/unit/util/primitives.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ test('primitives', (t) => {

t.test('frustum', (t) => {
t.test('Create a frustum from inverse projection matrix', (t) => {
const proj = new Float64Array(16); // [] also passes test
const invProj = new Float64Array(16); // [] also passes test
// FAIL const proj = mat4.create(); // Float32Array also fails
// FAIL const invProj = mat4.create(); // Float32Array also fails
const proj = new Float64Array(16);
const invProj = new Float64Array(16);
mat4.perspective(proj, Math.PI / 2, 1.0, 0.1, 100.0);
mat4.invert(invProj, proj);

Expand Down