Skip to content

Commit

Permalink
Merge branch 'master' into felix/remove-updateModuleSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer authored Sep 26, 2024
2 parents cbf20d8 + 728d9a6 commit 0af3044
Show file tree
Hide file tree
Showing 38 changed files with 820 additions and 145 deletions.
36 changes: 20 additions & 16 deletions docs/api-reference/carto/data-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {vectorTableSource} from '@deck.gl/carto';
const data = vectorTableSource({
accessToken: 'XXX',
connectionName: 'carto_dw',
tableName: 'carto-demo-data.demo_tables.chicago_crime_sample',
})
tableName: 'carto-demo-data.demo_tables.chicago_crime_sample'
});
```

### Promise API
Expand Down Expand Up @@ -51,7 +51,7 @@ type SourceOptions = {
apiBaseUrl?: string;
clientId?: string;
headers?: Record<string, string>;
mapsUrl?: string;
maxLengthURL?: number;
};
```

Expand All @@ -64,7 +64,7 @@ type VectorTableSourceOptions = {
columns?: string[];
spatialDataColumn?: string;
tableName: string;
}
};
```

#### vectorQuerySource
Expand All @@ -74,15 +74,15 @@ type VectorQuerySourceOptions = {
spatialDataColumn?: string;
sqlQuery: string;
queryParameters: QueryParameters;
}
};
```

#### vectorTilesetSource

```ts
type VectorTilesetSourceOptions = {
tableName: string;
}
};
```

#### h3TableSource
Expand All @@ -94,7 +94,7 @@ type H3TableSourceOptions = {
columns?: string[];
spatialDataColumn?: string;
tableName: string;
}
};
```

#### h3QuerySource
Expand All @@ -106,15 +106,15 @@ type H3QuerySourceOptions = {
spatialDataColumn?: string;
sqlQuery: string;
queryParameters: QueryParameters;
}
};
```

#### h3TilesetSource

```ts
type H3TilesetSourceOptions = {
tableName: string;
}
};
```

#### quadbinTableSource
Expand All @@ -126,7 +126,7 @@ type QuadbinTableSourceOptions = {
columns?: string[];
spatialDataColumn?: string;
tableName: string;
}
};
```

#### quadbinQuerySource
Expand All @@ -138,23 +138,23 @@ type QuadbinQuerySourceOptions = {
spatialDataColumn?: string;
sqlQuery: string;
queryParameters: QueryParameters;
}
};
```

#### quadbinTilesetSource

```ts
type QuadbinTilesetSourceOptions = {
tableName: string;
}
};
```

#### rasterTilesetSource (Experimental)

```ts
type RasterTilesetSourceOptions = {
tableName: string;
}
};
```

Boundary sources are experimental sources where both the tileset and the properties props need a specific schema to work. [Read more about Boundaries in the CARTO documentation](https://docs.carto.com/carto-for-developers/guides/use-boundaries-in-your-application).
Expand All @@ -166,7 +166,7 @@ type BoundaryTableSourceOptions = {
tilesetTableName: string;
columns?: string[];
propertiesTableName: string;
}
};
```

#### boundaryQuerySource (Experimental)
Expand All @@ -176,14 +176,15 @@ type BoundaryQuerySourceOptions = {
tilesetTableName: string;
propertiesSqlQuery: string;
queryParameters?: QueryParameters;
}
};
```

### QueryParameters

QueryParameters are used to parametrize SQL queries. The format depends on the source's provider, some examples:

[PostgreSQL and Redshift](https://node-postgres.com/features/queries):

```ts
vectorQuerySource({
...,
Expand All @@ -193,6 +194,7 @@ vectorQuerySource({
```

[BigQuery positional](https://cloud.google.com/bigquery/docs/parameterized-queries#node.js):

```ts
vectorQuerySource({
...,
Expand All @@ -201,8 +203,8 @@ vectorQuerySource({
})
```

[BigQuery named parameters](https://cloud.google.com/bigquery/docs/parameterized-queries#node.js):

```ts
vectorQuerySource({
...,
Expand All @@ -212,6 +214,7 @@ vectorQuerySource({
```

[Snowflake positional](https://docs.snowflake.com/en/user-guide/nodejs-driver-use.html#binding-statement-parameters) :

```ts
vectorQuerySource({
...,
Expand All @@ -230,6 +233,7 @@ vectorQuerySource({
```

[Databricks ODBC](https://github.com/markdirish/node-odbc#bindparameters-callback)

```ts
vectorQuerySource({
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type AggregatorTransformProps = {
binIdRange: NumberArray4;
isCount: NumberArray3;
isMean: NumberArray3;
naN: number;
bins: Texture;
};

Expand All @@ -25,7 +24,6 @@ export const aggregatorTransformUniforms = {
uniformTypes: {
binIdRange: 'vec4<i32>',
isCount: 'vec3<f32>',
isMean: 'vec3<f32>',
naN: 'f32'
isMean: 'vec3<f32>'
}
} as const satisfies ShaderModule<AggregatorTransformProps>;
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export class WebGLAggregationTransform {
this.device = device;
this.channelCount = props.channelCount;
this.transform = createTransform(device, props);
// Passed in as uniform because 1) there is no GLSL symbol for NaN 2) any expression that exploits undefined behavior to produces NaN
// will subject to platform differences and shader optimization
this.transform.model.shaderInputs.setProps({aggregatorTransform: {naN: NaN}});
this.domainFBO = createRenderTarget(device, 2, 1);
}

Expand Down Expand Up @@ -145,6 +142,8 @@ flat out vec2 values;
flat out vec3 values;
#endif
const float NAN = intBitsToFloat(-1);
void main() {
int row = gl_VertexID / SAMPLER_WIDTH;
int col = gl_VertexID - row * SAMPLER_WIDTH;
Expand All @@ -155,7 +154,7 @@ void main() {
aggregatorTransform.isMean
);
if (weights.a == 0.0) {
value3 = vec3(aggregatorTransform.naN);
value3 = vec3(NAN);
}
#if NUM_DIMS == 1
Expand Down Expand Up @@ -199,11 +198,6 @@ flat in vec3 values;
out vec4 fragColor;
void main() {
#if NUM_CHANNELS > 1
if (isnan(values.x)) discard;
#else
if (isnan(values)) discard;
#endif
vec3 value3;
#if NUM_CHANNELS == 3
value3 = values;
Expand All @@ -212,6 +206,7 @@ void main() {
#else
value3.x = values;
#endif
if (isnan(value3.x)) discard;
// This shader renders into a 2x1 texture with blending=max
// The left pixel yields the max value of each channel
// The right pixel yields the min value of each channel
Expand Down
51 changes: 27 additions & 24 deletions modules/arcgis/src/commons.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable no-invalid-this */

import {GL} from '@luma.gl/constants';
import {Model, Geometry} from '@luma.gl/engine';
import {Deck} from '@deck.gl/core';
import type {Device, Texture, Framebuffer} from '@luma.gl/core';
import {Deck} from '@deck.gl/core';
import {Model, Geometry} from '@luma.gl/engine';
import {WebGLDevice} from '@luma.gl/webgl';

interface Renderer {
redraw: () => void;
Expand Down Expand Up @@ -146,33 +147,35 @@ export function render(
) {
const {model, deck, fbo} = resources;
const device = model.device;
// @ts-ignore device.getParametersWebGL should return `any` not `void`?
const screenFbo: Framebuffer = device.getParametersWebGL(GL.FRAMEBUFFER_BINDING);
const {width, height, ...viewState} = viewport;
if (device instanceof WebGLDevice) {
// @ts-ignore device.getParametersWebGL should return `any` not `void`?
const screenFbo: Framebuffer = device.getParametersWebGL(GL.FRAMEBUFFER_BINDING);
const {width, height, ...viewState} = viewport;

/* global window */
const dpr = window.devicePixelRatio;
const pixelWidth = Math.round(width * dpr);
const pixelHeight = Math.round(height * dpr);
/* global window */
const dpr = window.devicePixelRatio;
const pixelWidth = Math.round(width * dpr);
const pixelHeight = Math.round(height * dpr);

fbo.resize({width: pixelWidth, height: pixelHeight});
fbo.resize({width: pixelWidth, height: pixelHeight});

deck.setProps({viewState});
// redraw deck immediately into deckFbo
deck.redraw('arcgis');
deck.setProps({viewState});
// redraw deck immediately into deckFbo
deck.redraw('arcgis');

// We overlay the texture on top of the map using the full-screen quad.
// We overlay the texture on top of the map using the full-screen quad.

const textureToScreenPass = device.beginRenderPass({
framebuffer: screenFbo,
parameters: {viewport: [0, 0, pixelWidth, pixelHeight]},
clearColor: false,
clearDepth: false
});
try {
model.draw(textureToScreenPass);
} finally {
textureToScreenPass.end();
const textureToScreenPass = device.beginRenderPass({
framebuffer: screenFbo,
parameters: {viewport: [0, 0, pixelWidth, pixelHeight]},
clearColor: false,
clearDepth: false
});
try {
model.draw(textureToScreenPass);
} finally {
textureToScreenPass.end();
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion modules/carto/src/api/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
export const DEFAULT_CLIENT = 'deck-gl-carto';
export const V3_MINOR_VERSION = '3.4';
export const MAX_GET_LENGTH = 8192;

// Fastly default limit is 8192; leave some padding.
export const DEFAULT_MAX_LENGTH_URL = 7000;
Loading

0 comments on commit 0af3044

Please sign in to comment.