• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 24153816851

08 Apr 2026 07:17PM UTC coverage: 53.247% (-12.1%) from 65.319%
24153816851

push

github

web-flow
chore: Move from tape to vitest (#3351)

8651 of 17291 branches covered (50.03%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 1 file covered. (100.0%)

2031 existing lines in 296 files now uncovered.

17563 of 31940 relevant lines covered (54.99%)

5279.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.61
/modules/json/src/lib/encoder-utils/encode-utils.ts
1
// loaders.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4
// Copyright 2022 Foursquare Labs, Inc.
5

6
import type {Table} from '@loaders.gl/schema';
7
import {getTableLength, getTableNumCols, getTableRowAsArray} from '@loaders.gl/schema-utils';
8

9
type Row = {[key: string]: unknown};
10

11
/**
12
 * Attempts to identify which column contains geometry
13
 * Currently just returns name (key) of first object-valued column
14
 * @todo look for hints in schema metadata
15
 * @todo look for WKB
16
 */
17
export function detectGeometryColumnIndex(table: Table): number {
18
  // TODO - look for hints in schema metadata
19

20
  // look for a column named geometry
21
  const geometryIndex = table.schema?.fields.findIndex(field => field.name === 'geometry') ?? -1;
2!
22
  if (geometryIndex > -1) {
2!
23
    return geometryIndex;
2✔
24
  }
25

26
  // look at the data
27
  // TODO - this drags in the indices
UNCOV
28
  if (getTableLength(table) > 0) {
×
UNCOV
29
    const row = getTableRowAsArray(table, 0);
×
UNCOV
30
    for (let columnIndex = 0; columnIndex < getTableNumCols(table); columnIndex++) {
×
UNCOV
31
      const value = row?.[columnIndex];
×
UNCOV
32
      if (value && typeof value === 'object') {
×
33
        return columnIndex;
×
34
      }
35
    }
36
  }
37

38
  throw new Error('Failed to detect geometry column');
×
39
}
40

41
/**
42
 * Return a row as a property (key/value) object, excluding selected columns
43
 */
44
export function getRowPropertyObject(
45
  table: Table,
46
  row: Row,
47
  excludeColumnIndices: number[] = []
6✔
48
): {[columnName: string]: unknown} {
49
  const properties = {};
6✔
50
  for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
6✔
51
    const columnName = table.schema?.fields[columnIndex].name;
24✔
52
    if (columnName && !excludeColumnIndices.includes(columnIndex)) {
24✔
53
      properties[columnName] = row[columnName];
18✔
54
    }
55
  }
56
  return properties;
6✔
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc