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

visgl / loaders.gl / 24139120841

08 Apr 2026 01:53PM UTC coverage: 65.319% (+30.2%) from 35.137%
24139120841

push

github

web-flow
chore: Replace puppeteer with playwright (#3350)

14216 of 18890 branches covered (75.26%)

Branch coverage included in aggregate %.

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

3248 existing lines in 369 files now uncovered.

73509 of 115413 relevant lines covered (63.69%)

5763.45 hits per line

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

93.26
/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✔
UNCOV
11
export function transformBinaryCoords(
×
12
  binaryFeatures: BinaryFeatureCollection,
1✔
13
  transformCoordinate: TransformCoordinate
1✔
14
): BinaryFeatureCollection {
1✔
15
  if (binaryFeatures.points) {
1✔
16
    transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);
1!
17
  }
1✔
18
  if (binaryFeatures.lines) {
1!
19
    transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);
✔
20
  }
1✔
21
  if (binaryFeatures.polygons) {
1!
22
    transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);
1✔
23
  }
1✔
24
  return binaryFeatures;
1✔
25
}
1✔
26

1✔
27
/** Transform one binary geometry */
1✔
28
function transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: TransformCoordinate) {
1✔
29
  const {positions} = binaryGeometry;
1✔
30
  for (let i = 0; i < positions.value.length; i += positions.size) {
3✔
31
    // @ts-ignore inclusion of bigint causes problems
11✔
32
    const coord: Array<number> = Array.from(positions.value.subarray(i, i + positions.size));
1✔
33
    const transformedCoord = fn(coord);
183✔
34
    // @ts-ignore typescript typing for .set seems to require bigint?
172✔
35
    positions.value.set(transformedCoord, i);
1✔
36
  }
1✔
37
}
1✔
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[],
3✔
47
  fn: (coord: number[]) => number[]
3✔
48
): Feature[] {
3✔
49
  for (const feature of features) {
3✔
50
    // @ts-ignore
11✔
51
    feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);
11✔
52
  }
11✔
53
  return features;
3✔
54
}
3✔
55

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

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

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