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

visgl / loaders.gl / 20352515932

18 Dec 2025 09:56PM UTC coverage: 35.115% (-28.4%) from 63.485%
20352515932

push

github

web-flow
feat(loader-utils): Export is-type helpers (#3258)

1188 of 1998 branches covered (59.46%)

Branch coverage included in aggregate %.

147 of 211 new or added lines in 13 files covered. (69.67%)

30011 existing lines in 424 files now uncovered.

37457 of 108056 relevant lines covered (34.66%)

0.79 hits per line

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

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

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

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

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

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

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

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

1✔
41
/**
1✔
42
 * Return a row as a property (key/value) object, excluding selected columns
1✔
43
 */
1✔
44
export function getRowPropertyObject(
1✔
UNCOV
45
  table: Table,
×
UNCOV
46
  row: Row,
×
UNCOV
47
  excludeColumnIndices: number[] = []
×
UNCOV
48
): {[columnName: string]: unknown} {
×
UNCOV
49
  const properties = {};
×
UNCOV
50
  for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
×
UNCOV
51
    const columnName = table.schema?.fields[columnIndex].name;
×
UNCOV
52
    if (columnName && !excludeColumnIndices.includes(columnIndex)) {
×
UNCOV
53
      properties[columnName] = row[columnName];
×
UNCOV
54
    }
×
UNCOV
55
  }
×
UNCOV
56
  return properties;
×
UNCOV
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