• 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

75.68
/src/dataStore/multimap/file.ts
1
import { S2FileStore } from '../file';
2
import { compareIDs } from '../..';
3

4
import type { FileEntry } from '../file';
5
import type { S2CellId } from '../..';
6
import type { MMEntry, MultiMapStore } from '.';
7
import type { Properties, Value } from '../..';
8

9
/** File based multimap store */
10
export class FileMultiMap<V = Properties | Value> implements MultiMapStore<V> {
11
  #store: S2FileStore<V>;
2✔
12

13
  /**
14
   * Builds a new MultiMap file store
15
   * @param fileName - the path + file name without the extension
16
   */
17
  constructor(fileName?: string) {
74✔
18
    this.#store = new S2FileStore<V>(fileName);
196✔
19
  }
20

21
  /** @returns - the length of the map */
22
  get length(): number {
32✔
23
    return this.#store.length;
126✔
24
  }
25

26
  /**
27
   * Adds a value to the list of values associated with a key
28
   * @param key - the key
29
   * @param value - the value to store
30
   */
31
  set(key: number | S2CellId, value: V): void {
66✔
UNCOV
32
    this.#store.set(BigInt(key), value);
×
UNCOV
33
  }
×
UNCOV
34

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

44
  /**
45
   * Gets the list of values associated with a key
46
   * @param key - the key
47
   * @returns the list of values if the map contains values for the key
48
   */
49
  async get(key: number | S2CellId): Promise<V[] | undefined> {
38✔
50
    return await this.#store.get(BigInt(key));
206✔
51
  }
52

53
  /**
54
   * iterate through the values
55
   * @yields - The values in the store
56
   */
57
  async *entries(): AsyncGenerator<MMEntry<V>> {
32✔
58
    let entries: FileEntry<V>[] = [];
84✔
59
    for await (const entry of this.#store.entries()) {
214✔
60
      if (entries.length > 0) {
122✔
61
        const curr = entries[0];
128✔
62
        if (compareIDs(curr.key, entry.key) === 0) {
206✔
63
          entries.push(entry);
148✔
64
        } else {
34✔
65
          yield { key: curr.key, value: entries.map((e) => e.value) };
276✔
66
          entries = [entry];
166✔
67
        }
68
      } else {
34✔
69
        entries.push(entry);
150✔
70
      }
71
    }
6✔
72
    if (entries.length > 0) yield { key: entries[0].key, value: entries.map((e) => e.value) };
404✔
73
  }
74

75
  /**
76
   * iterate through the values
77
   * @returns - an iterator
78
   */
79
  [Symbol.asyncIterator](): AsyncGenerator<MMEntry<V>> {
62✔
80
    return this.entries();
110✔
81
  }
82

83
  /** Closes the store */
84
  close(): void {
30✔
85
    this.#store.close(true);
122✔
86
  }
87
}
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