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

visgl / loaders.gl / 24112850045

08 Apr 2026 01:31AM UTC coverage: 35.137% (+0.003%) from 35.134%
24112850045

push

github

web-flow
chore: biome replaces eslint/prettier (#3349)

1225 of 2057 branches covered (59.55%)

Branch coverage included in aggregate %.

55 of 603 new or added lines in 172 files covered. (9.12%)

1 existing line in 1 file now uncovered.

39942 of 115105 relevant lines covered (34.7%)

0.77 hits per line

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

31.94
/modules/json/src/lib/encoder-utils/encode-table-row.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 {Feature, Table} from '@loaders.gl/schema';
1✔
7
import {getTableRowAsObject} from '@loaders.gl/schema-utils';
1✔
8
import {getRowPropertyObject} from './encode-utils';
1✔
9
import {Utf8ArrayBufferEncoder} from './utf8-encoder';
1✔
10

1✔
11
type Row = {[key: string]: unknown};
1✔
12

1✔
13
// Helpers
1✔
14

1✔
15
/**
1✔
16
 * Encode a row. Currently this ignores properties in the geometry column.
1✔
17
 */
1✔
18
export function encodeTableRow(
1✔
19
  table: Table,
×
20
  rowIndex: number,
×
21
  geometryColumnIndex: number,
×
22
  utf8Encoder: Utf8ArrayBufferEncoder
×
23
): void {
×
24
  const row = getTableRowAsObject(table, rowIndex);
×
25
  if (!row) return;
×
26
  const featureWithProperties = getFeatureFromRow(table, row, geometryColumnIndex);
×
27
  const featureString = JSON.stringify(featureWithProperties);
×
28
  utf8Encoder.push(featureString);
×
29
}
×
30

1✔
31
/**
1✔
32
 * Encode a row as a Feature. Currently this ignores properties objects in the geometry column.
1✔
33
 */
1✔
34
function getFeatureFromRow(table: Table, row: Row, geometryColumnIndex: number): Feature {
×
35
  // Extract non-feature/geometry properties
×
36
  const properties = getRowPropertyObject(table, row, [geometryColumnIndex]);
×
37

×
38
  // Extract geometry feature
×
39
  const columnName = table.schema?.fields[geometryColumnIndex].name;
×
40
  let featureOrGeometry =
×
41
    columnName && (row[columnName] as {[key: string]: unknown} | string | null | undefined);
×
42

×
43
  // GeoJSON support null geometries
×
44
  if (!featureOrGeometry) {
×
45
    // @ts-ignore Feature type does not support null geometries
×
46
    return {type: 'Feature', geometry: null, properties};
×
47
  }
×
48

×
49
  // Support string geometries?
×
50
  // TODO: This assumes GeoJSON strings, which may not be the correct format
×
51
  // (could be WKT, encoded WKB...)
×
52
  if (typeof featureOrGeometry === 'string') {
×
53
    try {
×
54
      featureOrGeometry = JSON.parse(featureOrGeometry);
×
NEW
55
    } catch (_err) {
×
56
      throw new Error('Invalid string geometry');
×
57
    }
×
58
  }
×
59

×
60
  if (typeof featureOrGeometry !== 'object' || typeof featureOrGeometry?.type !== 'string') {
×
61
    throw new Error('invalid geometry column value');
×
62
  }
×
63

×
64
  if (featureOrGeometry?.type === 'Feature') {
×
65
    // @ts-ignore Feature type does not support null geometries
×
66
    return {...featureOrGeometry, properties};
×
67
  }
×
68

×
69
  // @ts-ignore Feature type does not support null geometries
×
70
  return {type: 'Feature', geometry: featureOrGeometry, properties};
×
71
}
×
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