Skip to content

Commit 6025eae

Browse files
committed
Allow user to specify as_geo to create geoparquet files as opposed to plain vanilla parquet
Fixes #719
1 parent 589eaae commit 6025eae

File tree

3 files changed

+56
-20
lines changed

3 files changed

+56
-20
lines changed

web-client/src/stores/gradientColorMapStore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export function useGradientColorMapStore(reqIdStr: string) {
7676
max: maxValue,
7777
valueAccessor: (params: any) => {
7878
if (ndx < 0) ndx = dataOrderNdx[ndx_name];
79-
return params.data[ndx];
79+
const value = params.data[ndx];
80+
// Convert BigInt to Number if necessary
81+
return typeof value === 'bigint' ? Number(value) : value;
8082
}
8183
});
8284
}

web-client/src/utils/SrDuckDbUtils.ts

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,34 +1329,56 @@ export async function fetchScatterData(
13291329
if (handleMinMaxRow) {
13301330
handleMinMaxRow(reqIdStr, row);
13311331
} else {
1332+
// Convert to number first if BigInt
1333+
const rawMinX = typeof row[aliasKey("min", `${x}`)] === 'bigint'
1334+
? Number(row[aliasKey("min", `${x}`)])
1335+
: row[aliasKey("min", `${x}`)];
1336+
const rawMaxX = typeof row[aliasKey("max", `${x}`)] === 'bigint'
1337+
? Number(row[aliasKey("max", `${x}`)])
1338+
: row[aliasKey("max", `${x}`)];
1339+
13321340
if(options.parentMinX){
13331341
minXtoUse = options.parentMinX;
13341342
} else {
1335-
minXtoUse = row[aliasKey("min", `${x}`)];
1343+
minXtoUse = rawMinX;
13361344
}
1337-
if(minXtoUse === row[aliasKey("min", `${x}`)]){
1338-
console.log('fetchScatterData minXtoUse:', minXtoUse, `row['min_${x}']:`, row[aliasKey("min", `${x}`)]);
1345+
if(minXtoUse === rawMinX){
1346+
console.log('fetchScatterData minXtoUse:', minXtoUse, `row['min_${x}']:`, rawMinX);
13391347
} else {
1340-
console.warn('fetchScatterData minXtoUse:', minXtoUse, `row['min_${x}']:`, row[aliasKey("min", `${x}`)]);
1348+
console.warn('fetchScatterData minXtoUse:', minXtoUse, `row['min_${x}']:`, rawMinX);
13411349
}
13421350
// set min/max in the store
1343-
useChartStore().setRawMinX(reqIdStr, row[aliasKey("min", `${x}`)]);
1344-
useChartStore().setMinX(reqIdStr, row[aliasKey("min", `${x}`)] - minXtoUse);
1345-
useChartStore().setMaxX(reqIdStr, row[aliasKey("max", `${x}`)] - minXtoUse);
1351+
useChartStore().setRawMinX(reqIdStr, rawMinX);
1352+
useChartStore().setMinX(reqIdStr, rawMinX - minXtoUse);
1353+
useChartStore().setMaxX(reqIdStr, rawMaxX - minXtoUse);
13461354
}
13471355

13481356
// Populate minMaxValues, but exclude NaN values (should be unnecessary now that we filter in SQL)
1349-
if (!isNaN(row[aliasKey("min", `${x}`)]) && !isNaN(row[aliasKey("max", `${x}`)])) {
1357+
// Convert to number first if BigInt
1358+
const minX = typeof row[aliasKey("min", `${x}`)] === 'bigint'
1359+
? Number(row[aliasKey("min", `${x}`)])
1360+
: row[aliasKey("min", `${x}`)];
1361+
const maxX = typeof row[aliasKey("max", `${x}`)] === 'bigint'
1362+
? Number(row[aliasKey("max", `${x}`)])
1363+
: row[aliasKey("max", `${x}`)];
1364+
const lowX = typeof row[aliasKey("low", `${x}`)] === 'bigint'
1365+
? Number(row[aliasKey("low", `${x}`)])
1366+
: row[aliasKey("low", `${x}`)];
1367+
const highX = typeof row[aliasKey("high", `${x}`)] === 'bigint'
1368+
? Number(row[aliasKey("high", `${x}`)])
1369+
: row[aliasKey("high", `${x}`)];
1370+
1371+
if (!isNaN(minX) && !isNaN(maxX)) {
13501372
minMaxLowHigh[`x`] = { // genericize the name to x
1351-
min: row[aliasKey("min", `${x}`)],
1352-
max: row[aliasKey("max", `${x}`)],
1353-
low: row[aliasKey("low", `${x}`)],
1354-
high: row[aliasKey("high", `${x}`)]
1373+
min: minX,
1374+
max: maxX,
1375+
low: lowX,
1376+
high: highX
13551377
}
1356-
1378+
13571379
} else {
13581380
console.log('aliasKey("min", x):',aliasKey("min", `${x}`));
1359-
console.error('fetchScatterData: min/max x is NaN:', row[aliasKey("min", `${x}`)], row[aliasKey("max", `${x}`)]);
1381+
console.error('fetchScatterData: min/max x is NaN:', minX, maxX);
13601382
}
13611383

13621384
y.forEach((yName) => {
@@ -1461,18 +1483,24 @@ export async function fetchScatterData(
14611483
);
14621484
} else {
14631485
// Default transformation:
1464-
const xVal = normalizeX ? row[x] - minXtoUse : row[x];
1486+
// Convert to number first if BigInt
1487+
const xRawVal = typeof row[x] === 'bigint' ? Number(row[x]) : row[x];
1488+
const xVal = normalizeX ? xRawVal - minXtoUse : xRawVal;
14651489
rowValues = [xVal];
14661490
orderNdx = setDataOrder(dataOrderNdx, 'x', orderNdx);
14671491

14681492
y.forEach((yName) => {
1469-
rowValues.push(row[yName]);
1493+
// Convert to number first if BigInt
1494+
const yVal = typeof row[yName] === 'bigint' ? Number(row[yName]) : row[yName];
1495+
rowValues.push(yVal);
14701496
orderNdx = setDataOrder(dataOrderNdx, yName, orderNdx);
14711497
});
14721498

14731499
if (extraSelectColumns.length > 0) {
14741500
extraSelectColumns.forEach((colName) => {
1475-
rowValues.push(row[colName]);
1501+
// Convert to number first if BigInt
1502+
const colVal = typeof row[colName] === 'bigint' ? Number(row[colName]) : row[colName];
1503+
rowValues.push(colVal);
14761504
orderNdx = setDataOrder(dataOrderNdx, colName, orderNdx);
14771505
});
14781506
}

web-client/src/utils/colorUtils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export function createUnifiedColorMapper(options: {
3737
max: number;
3838
valueAccessor: (input: any) => number;
3939
}) {
40-
const { colorMap, min, max, valueAccessor } = options;
40+
const { colorMap, valueAccessor } = options;
41+
// Convert BigInt to Number if necessary
42+
const min = typeof options.min === 'bigint' ? Number(options.min) : options.min;
43+
const max = typeof options.max === 'bigint' ? Number(options.max) : options.max;
4144
const numShades = colorMap.length;
4245
const range = max - min;
4346
const scale = (numShades - 1) / range;
@@ -60,7 +63,10 @@ export function createUnifiedColorMapperRGBA(options: {
6063
max: number;
6164
valueAccessor: (input: any) => number;
6265
}): (input: any) => [number, number, number, number] {
63-
const { colorMap, min, max, valueAccessor } = options;
66+
const { colorMap, valueAccessor } = options;
67+
// Convert BigInt to Number if necessary
68+
const min = typeof options.min === 'bigint' ? Number(options.min) : options.min;
69+
const max = typeof options.max === 'bigint' ? Number(options.max) : options.max;
6470
const numShades = colorMap.length;
6571
const range = max - min;
6672
const scale = (numShades - 1) / range;

0 commit comments

Comments
 (0)