• 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

34.78
/modules/gis/src/lib/binary-geometry-api/transform-coordinates.ts
1
import type {BinaryFeatureCollection, BinaryGeometry, Feature} from '@loaders.gl/schema';
1✔
2

1✔
3
type TransformCoordinate = (coord: number[]) => number[];
1✔
4

1✔
5
/**
1✔
6
 * Apply transformation to every coordinate of binary features
1✔
7
 * @param  binaryFeatures binary features
1✔
8
 * @param  transformCoordinate Function to call on each coordinate
1✔
9
 * @return Transformed binary features
1✔
10
 */
1✔
11
export function transformBinaryCoords(
1✔
12
  binaryFeatures: BinaryFeatureCollection,
×
13
  transformCoordinate: TransformCoordinate
×
14
): BinaryFeatureCollection {
×
15
  if (binaryFeatures.points) {
×
16
    transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);
×
17
  }
×
18
  if (binaryFeatures.lines) {
×
19
    transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);
×
20
  }
×
21
  if (binaryFeatures.polygons) {
×
22
    transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);
×
23
  }
×
24
  return binaryFeatures;
×
25
}
×
26

1✔
27
/** Transform one binary geometry */
1✔
28
function transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: TransformCoordinate) {
×
29
  const {positions} = binaryGeometry;
×
30
  for (let i = 0; i < positions.value.length; i += positions.size) {
×
31
    // @ts-ignore inclusion of bigint causes problems
×
32
    const coord: Array<number> = Array.from(positions.value.subarray(i, i + positions.size));
×
33
    const transformedCoord = fn(coord);
×
34
    // @ts-ignore typescript typing for .set seems to require bigint?
×
35
    positions.value.set(transformedCoord, i);
×
36
  }
×
37
}
×
38

1✔
39
/**
1✔
40
 * Apply transformation to every coordinate of GeoJSON features
1✔
41
 * @param  features Array of GeoJSON features
1✔
42
 * @param  fn       Function to call on each coordinate
1✔
43
 * @return          Transformed GeoJSON features
1✔
44
 */
1✔
45
export function transformGeoJsonCoords(
1✔
46
  features: Feature[],
×
47
  fn: (coord: number[]) => number[]
×
48
): Feature[] {
×
49
  for (const feature of features) {
×
50
    // @ts-ignore
×
51
    feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);
×
52
  }
×
53
  return features;
×
54
}
×
55

1✔
56
function coordMap(array: unknown, fn: (coord: number[]) => number[]): unknown[] {
×
57
  if (isCoord(array)) {
×
58
    return fn(array as number[]);
×
59
  }
×
60

×
NEW
61
  return (array as unknown[]).map(item => {
×
62
    return coordMap(item, fn);
×
63
  });
×
64
}
×
65

1✔
66
function isCoord(array: unknown) {
×
67
  return Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);
×
68
}
×
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