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

Open-S2 / gis-tools / #6

23 Jan 2025 11:00PM UTC coverage: 92.693% (-0.3%) from 93.021%
#6

push

Mr Martian
gridCluster done; toTiles setup without tests; dataStores add has; fixed geometry 3dpoint to normalize from wm and s2 data

120 of 399 new or added lines in 24 files covered. (30.08%)

26 existing lines in 9 files now uncovered.

59825 of 64541 relevant lines covered (92.69%)

95.07 hits per line

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

68.97
/src/dataStore/vector/file.ts
1
import { S2FileStore } from '../file';
2

3
import type { S2CellId } from '../..';
4
import type { VectorKey, VectorStore } from '.';
5

6
/** File based vector store */
7
export class FileVector<V extends VectorKey> implements VectorStore<V> {
8
  #store: S2FileStore;
2✔
9
  /** @param fileName - the path + file name without the extension */
10
  constructor(fileName?: string) {
74✔
11
    this.#store = new S2FileStore<V>(fileName);
196✔
12
  }
13

14
  /** @returns the length of the store */
15
  get length(): number {
32✔
16
    return this.#store.length;
126✔
17
  }
18

19
  /**
20
   * Push a value into the store
21
   * @param value - the value to store
22
   */
23
  push(value: V): void {
48✔
24
    this.#store.set(value.cell, value);
178✔
25
  }
26

27
  /**
28
   * @param index - the position in the store to get the value from
29
   * @returns the value
30
   */
31
  async get(index: number | S2CellId): Promise<V> {
46✔
32
    const value = await this.#store.get(BigInt(index));
220✔
33
    if (value === undefined) throw new Error('Value not found');
204✔
UNCOV
34
    return value[0] as V;
×
UNCOV
35
  }
×
UNCOV
36

×
NEW
37
  /**
×
NEW
38
   * Check if the key exists
×
NEW
39
   * @param key - the key
×
NEW
40
   * @returns true if the key exists
×
NEW
41
   */
×
NEW
42
  async has(key: number | S2CellId): Promise<boolean> {
×
43
    return await this.#store.has(BigInt(key));
112✔
44
  }
45

46
  /** Sort the store */
47
  async sort(): Promise<void> {
28✔
48
    await this.#store.sort();
144✔
49
  }
50

51
  /**
52
   * iterate through the values
53
   * @yields an iterator
54
   */
55
  async *values(): AsyncGenerator<V> {
30✔
56
    for await (const { value } of this.#store.entries()) yield value as V;
308✔
57
  }
58

59
  /**
60
   * iterate through the values
61
   * @returns an iterator
62
   */
63
  [Symbol.asyncIterator](): AsyncGenerator<V> {
62✔
64
    return this.values();
106✔
65
  }
66

67
  /** Closes the store */
68
  close(): void {
30✔
69
    this.#store.close(true);
122✔
70
  }
71
}
2✔
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