Skip to content

Commit dfe48d4

Browse files
committed
wip
1 parent 9d3250e commit dfe48d4

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

src/layers/src/geojson-layer/geojson-utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ export function groupColumnsAsGeoJson(
360360
for (let index = 0; index < dataContainer.numRows(); index++) {
361361
// note: can materialize the row
362362
const datum = dataContainer.rowAsArray(index);
363-
const id = datum[columns.id.fieldIdx];
363+
// Convert id to string to ensure consistent object key behavior
364+
// (numeric keys are sorted differently than string keys in Object.entries)
365+
const id = `${datum[columns.id.fieldIdx]}`;
364366
const lat = datum[columns.lat.fieldIdx];
365367
const lon = datum[columns.lng.fieldIdx];
366368
const altitude = columns.altitude ? datum[columns.altitude.fieldIdx] : 0;
@@ -420,7 +422,7 @@ export function detectTableColumns(
420422
// find sort by field
421423
const sortByFieldIdx = fields.findIndex(f => f.type === ALL_FIELD_TYPES.timestamp);
422424
// find id column
423-
const idFieldIdx = fields.findIndex(f => f.name?.toLowerCase().match(/^(id|uuid)$/g));
425+
const idFieldIdx = fields.findIndex(f => f.name?.toLowerCase().match(/(id|uuid)/g));
424426

425427
if (sortByFieldIdx > -1 && idFieldIdx > -1) {
426428
const pointColumns = assignPointPairToLayerColumn(fieldPairs[0], true);

src/layers/src/trip-layer/trip-layer.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export default class TripLayer extends Layer {
243243
}
244244

245245
static findDefaultLayerProps(
246-
{label, fields = [], dataContainer, id}: KeplerTable,
246+
{label, fields = [], dataContainer, id, fieldPairs = []}: KeplerTable,
247247
foundLayers?: any[]
248248
) {
249249
const geojsonColumns = fields.filter(f => f.type === 'geojson' || f.type === 'geoarrow' || f.type === 'geoarrow-wkb').map(f => f.name);
@@ -277,6 +277,39 @@ export default class TripLayer extends Layer {
277277
};
278278
}
279279

280+
// Try to detect table columns (id/lat/lng/timestamp) for table column mode
281+
// This allows creating trip layers from tabular data without GeoJSON
282+
if (fieldPairs.length && fields.length) {
283+
// Default layer columns for table mode
284+
const defaultTableColumns = {
285+
id: {value: null, fieldIdx: -1},
286+
lat: {value: null, fieldIdx: -1},
287+
lng: {value: null, fieldIdx: -1},
288+
timestamp: {value: null, fieldIdx: -1},
289+
altitude: {value: null, fieldIdx: -1, optional: true},
290+
geojson: {value: null, fieldIdx: -1}
291+
};
292+
293+
const tableColumns = detectTableColumns(
294+
{fields, fieldPairs} as KeplerTable,
295+
defaultTableColumns,
296+
'timestamp'
297+
);
298+
299+
if (tableColumns) {
300+
// Found required columns for table mode
301+
return {
302+
props: [{
303+
label: tableColumns.label || (typeof label === 'string' && label.replace(/\.[^/.]+$/, '')) || this.type,
304+
columns: tableColumns.columns,
305+
isVisible: true,
306+
columnMode: COLUMN_MODE_TABLE
307+
}],
308+
foundLayers
309+
};
310+
}
311+
}
312+
280313
return {props: []};
281314
}
282315

0 commit comments

Comments
 (0)