Skip to content

Commit

Permalink
Set default tileResolution=0.5, expand TSDoc descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Mar 7, 2024
1 parent aec1d97 commit 5f67202
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/carto/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const DEFAULT_TILE_SIZE = 512;
export const DEFAULT_TILE_RESOLUTION = 0.5;

export const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
export const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
25 changes: 22 additions & 3 deletions modules/carto/src/sources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ export type QuerySourceOptions = {
sqlQuery: string;

/**
* Relative resolution of a tile. Higher values increase density and data size. Default = 1.
* Relative resolution of a tile. Higher values increase density and data size. At tileResolution `1`, tile geometry is
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
* the quantization grid proportionately.
*
* Supported `tileResolution` values, with corresponding grid sizes:
*
* - 0.25: 256x256
* - 0.5: 512x512
* - 1: 1024x1024
* - 2: 2048x2048
* - 4: 4096x4096
*/
tileResolution?: TileResolution;

Expand Down Expand Up @@ -128,7 +138,17 @@ export type TableSourceOptions = {
spatialDataColumn?: string;

/**
* Relative resolution of a tile. Higher values increase density and data size. Default = 1.
* Relative resolution of a tile. Higher values increase density and data size. At tileResolution `1`, tile geometry is
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
* the quantization grid proportionately.
*
* Supported `tileResolution` values, with corresponding grid sizes:
*
* - 0.25: 256x256
* - 0.5: 512x512
* - 1: 1024x1024
* - 2: 2048x2048
* - 4: 4096x4096
*/
tileResolution?: TileResolution;
};
Expand Down Expand Up @@ -165,7 +185,6 @@ export interface Tilejson {
center: [number, number, number];
vector_layers: VectorLayer[];
tilestats: Tilestats;
/** Relative resolution of a tile. Higher values increase density and data size. */
tileResolution?: TileResolution;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/carto/src/sources/vector-query-source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable camelcase */
import {DEFAULT_TILE_RESOLUTION} from '../constants';
import {baseSource} from './base-source';
import type {
FilterOptions,
Expand Down Expand Up @@ -31,7 +32,7 @@ export const vectorQuerySource = async function (
filters,
spatialDataColumn = 'geom',
sqlQuery,
tileResolution = 1,
tileResolution = DEFAULT_TILE_RESOLUTION,
queryParameters
} = options;

Expand Down
9 changes: 8 additions & 1 deletion modules/carto/src/sources/vector-table-source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable camelcase */
import {DEFAULT_TILE_RESOLUTION} from '../constants';
import {baseSource} from './base-source';
import type {
FilterOptions,
Expand All @@ -21,7 +22,13 @@ type UrlParameters = {
export const vectorTableSource = async function (
options: VectorTableSourceOptions
): Promise<TilejsonResult> {
const {columns, filters, spatialDataColumn = 'geom', tableName, tileResolution = 1} = options;
const {
columns,
filters,
spatialDataColumn = 'geom',
tableName,
tileResolution = DEFAULT_TILE_RESOLUTION
} = options;

const urlParameters: UrlParameters = {
name: tableName,
Expand Down

0 comments on commit 5f67202

Please sign in to comment.