In this section
- Browser render · gridatlas / tools/satnav/survey/browser.py lines 1–103
- Interchange ingest · gridatlas / tools/satnav/survey/interchange.mjs lines 1–183
- Interchange Test test · gridatlas / tools/satnav/survey/interchange.test.mjs lines 1–103
- Model transform · gridatlas / tools/satnav/survey/model.mjs lines 1–131
- Model Test test · gridatlas / tools/satnav/survey/model.test.mjs lines 1–87
- Recorder transform · gridatlas / tools/satnav/track/recorder.mjs lines 1–26
- Recorder Test test · gridatlas / tools/satnav/track/recorder.test.mjs lines 1–21
Browser
A Python command-line tool in the survey folder of GridAtlas. It is built from the check step (`check`).
rendergridatlas / tools/satnav/survey/browser.py · lines 1–103 of 103 · Entry point
- What it does
- It loads data. Defines check. Uses libraries json, os, runpy, pathlib, playwright.sync_api. Side effects: changes the web page (DOM); reads or writes files.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- Test the actual survey controls and local download using simulated device fixes.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- gridatlas · tools/satnav/survey · Python CLI
- Uses
- json, os, runpy, pathlib, playwright.sync_api
- Used by
- none found
- Produces
- check
- Defines here
- check
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/survey/browser.py:1-103 · blob 48a1c6802bee933a63473fdb25a9872590cd3979 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
"""Test the actual survey controls and local download using simulated device fixes."""
import json
import os
import runpy
from pathlib import Path
from playwright.sync_api import expect, sync_playwright
GPS_SPY = runpy.run_path(str(Path(__file__).resolve().parents[1] / 'compact-browser.py'))['GPS_SPY']
SITE = os.environ.get('SURVEY_TEST_URL', 'http://127.0.0.1:8873/atlas/v/satnav-survey-202611281318/')
def check(browser, label, width, height):
context = browser.new_context(viewport={'width': width, 'height': height}, is_mobile=True,
has_touch=True, accept_downloads=True)
context.add_init_script(GPS_SPY)
page = context.new_page()
errors = []
page.on('pageerror', lambda error: errors.append(str(error)))
try:
page.goto(SITE, wait_until='domcontentloaded', timeout=60000)
scope = page.locator('#satnav-survey')
expect(page.locator('#satnav-from')).to_be_enabled(timeout=60000)
expect(scope.locator('summary')).to_be_visible(timeout=15000)
scope.locator('summary').tap()
expect(scope.get_by_role('button', name='Record track')).to_be_disabled()
assert page.evaluate('window.__lineGpsTest.records.starts') == []
page.locator('#satnav-location').tap()
page.evaluate('window.__lineGpsTest.emit([0, 51], 6)')
page.evaluate("""() => document.querySelector('#satnav-compact').satnavSurvey.replacePlan(
[[0,51], [.001,51], [.001,51.001]])""")
scope.get_by_role('button', name='Close perimeter').tap()
expect(scope.locator('[data-plan]')).to_contain_text('Planned perimeter')
scope.get_by_role('button', name='Record track').tap()
page.evaluate('window.__lineGpsTest.emit([0,51], 4)')
expect(scope.locator('[data-track]')).to_contain_text('1 fix')
page.evaluate('window.__lineGpsTest.emit([0.0001,51], 5)')
expect(scope.locator('[data-track]')).to_contain_text('2 fixes')
scope.get_by_role('button', name='Pause track').tap()
page.evaluate('window.__lineGpsTest.emit([.5,51], 5)')
scope.get_by_role('button', name='Resume track').tap()
page.evaluate('window.__lineGpsTest.emit([.001,51], 6)')
expect(scope.locator('[data-track]')).to_contain_text('3 fixes')
page.evaluate('window.__lineGpsTest.emit([.8,51], 75)')
page.evaluate('window.__lineGpsTest.emit([.0011,51], 9)')
expect(scope.locator('[data-track]')).to_contain_text('4 fixes')
page.locator('#satnav-stop').tap()
expect(scope.locator('[data-track]')).to_contain_text('Stopped')
expect(scope.get_by_role('button', name='Record track')).to_be_disabled()
assert page.evaluate('window.__lineGpsTest.records') == {'starts': [1], 'stops': [1]}
with page.expect_download(timeout=10000) as event:
scope.get_by_role('button', name='Export GeoJSON').tap()
download = event.value
assert download.suggested_filename.endswith('.geojson')
data = json.loads(Path(download.path()).read_text())
roles = [f['properties']['satnavRole'] for f in data['features']]
assert roles.count('waypoint') == 3 and roles.count('perimeter') == 1
assert roles.count('walked-track') == 1 and roles.count('walked-fix') == 2
measured = next(f for f in data['features'] if f['properties']['satnavRole'] == 'walked-track')
assert measured['geometry']['coordinates'] == [[0,51],[.0001,51]]
assert measured['properties']['accuracyM'] == [4,5]
assert measured['properties']['timestampMs'][1] > measured['properties']['timestampMs'][0]
page.wait_for_function("""() => window.__GRIDATLAS_V9_MAP__.getSource('satnav-field-survey')
?.serialize().data.features.filter(f => f.properties.satnavRole === 'walked-fix').length === 2""")
scope.get_by_role('button', name='Open perimeter').tap()
expect(scope.locator('[data-plan]')).to_be_empty()
# The follower bounds lateral deviation on long legs. Ordered compass guidance still returns to FROM.
long_ring = [[0, 51], [.02, 51], [.02, 51.001]]
guidance = page.locator('#satnav-guide')
page.locator('#satnav-location').tap()
page.evaluate('at => window.__lineGpsTest.emit(at, 3)', long_ring[0])
page.evaluate("pins => document.querySelector('#satnav-compact').satnavSurvey.replacePlan(pins)", long_ring)
scope.get_by_role('button', name='Close perimeter').tap()
expect(scope.locator('[data-plan]')).to_contain_text('Deviation unavailable on legs over 1 km')
for point, expected_target in zip(long_ring, ['Pin 2', 'Pin 3', 'Return to FROM']):
page.evaluate('at => window.__lineGpsTest.emit(at, 3)', point)
expect(guidance).to_contain_text(expected_target)
expect(guidance).to_contain_text('true')
expect(guidance).to_contain_text('remaining')
page.evaluate('at => window.__lineGpsTest.emit(at, 3)', long_ring[0])
expect(guidance).to_have_text('Arrived at the final pin')
page.locator('#satnav-stop').tap()
assert not errors, errors
print(f'{label} {width}×{height} · perimeter, watch, pause, gaps, actual GeoJSON download passed', flush=True)
finally:
context.close()
if __name__ == '__main__':
with sync_playwright() as playwright:
for engine in os.environ.get('SURVEY_BROWSERS', 'chromium,webkit').split(','):
options = {}
if engine == 'chromium':
options['args'] = ['--enable-webgl', '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader']
if os.environ.get('CHROMIUM_PATH'):
options['executable_path'] = os.environ['CHROMIUM_PATH']
browser = getattr(playwright, engine).launch(**options)
try:
for dimensions in [(390,664), (664,390)]:
check(browser, engine, *dimensions)
finally:
browser.close()Interchange
A JavaScript module in the survey folder of GridAtlas that counts coordinates, normalises feature and validates point order, covering 33kV, cables, substations and battery storage (BESS), using EPSG:4326.
ingestgridatlas / tools/satnav/survey/interchange.mjs · lines 1–183 of 183
- What it does
- It lists and searches 33kV, cables, substations and battery storage (BESS). Defines 8 functions or classes, including featuresOf, sampleProperty, countCoordinates, normaliseFeature, validatePointOrder.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work. Domain terms in the code: 33kV, cables, substations, battery storage (BESS).
- Inputs & outputs
- Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 33kV.
- Downstream impact
- Used directly by 2 files: Layout Import (gridatlas); Interchange Test (gridatlas). Reached from 2 other entry points, including GridAtlas PR File Size Guard Workflow (gridatlas); Layout Import Test (gridatlas).
- What it achieves
- It counts coordinates (`countCoordinates`), normalises feature (`normaliseFeature`) and validates point order (`validatePointOrder`). Bridge the two Ventus GeoJSON encodings without promoting measured fixes to design. Its code works with 33 kV.
- Why it matters
- Imported by Layout Import. Checked by Interchange Test.
- Application
- gridatlas · tools/satnav/survey · JavaScript module
- Uses
- GeoJSON (import)
- Used by
- imported by Layout Import (import), imported by Interchange Test (import)
- Produces
- GIS_TYPES, RADIAL_NAMES, readSurveyLayout, editableCoordinates
- Defines here
- featuresOf, sampleProperty, countCoordinates, normaliseFeature, validatePointOrder, validateMeasuredOrder, readSurveyLayout, editableCoordinates
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/survey/interchange.mjs:1-183 · blob c63189a64a8d14c5fd6157df3b271c00de2541e3 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
// SPDX-License-Identifier: Apache-2.0
// Bridge the two Ventus GeoJSON encodings without promoting measured fixes to design.
import { fromGisSnapshot, normaliseGeoJSON } from '../interchange/geojson.mjs';
const MAX_COORDINATES = 20000;
const roles = new Set(['waypoint', 'planned-route', 'perimeter', 'walked-track', 'walked-fix']);
const defaultRole = { Point: 'waypoint', LineString: 'planned-route', Polygon: 'perimeter' };
export const GIS_TYPES = {
export_cable: ['LineString', 'Export cable'],
'33kv_radial': ['LineString', '33 kV radial'],
export_cable_pin: ['Point', 'Cable pin'],
poi: ['Point', 'Grid connection'],
private_sub: ['Point', 'Customer substation'],
string_substation: ['Point', 'String substation'],
central_inverter: ['Point', 'Central inverter'],
bess_compound: ['Point', 'BESS compound'],
array_boundary: ['Polygon', 'Array boundary'],
skid_footprint: ['Polygon', 'Skid footprint'],
central_footprint: ['Polygon', 'Central inverter footprint'],
bess_footprint: ['Polygon', 'BESS footprint'],
};
export const RADIAL_NAMES = {
collector_trunk: '33 kV collector trunk',
block_branch: '33 kV block branch',
};
const geographicReferences = new Set([
'EPSG:4326', 'OGC:CRS84', 'urn:ogc:def:crs:OGC:1.3:CRS84', 'urn:ogc:def:crs:EPSG::4326',
]);
function featuresOf(data) {
if (data?.type === 'FeatureCollection') return data.features;
if (data?.type === 'Feature') return [data];
if (Object.hasOwn(defaultRole, data?.type)) return [{type: 'Feature', geometry: data}];
throw new Error('Expected a GeoJSON point, line, polygon or feature collection');
}
function sampleProperty(properties, key, legacyKey) {
if (properties[key] !== undefined && properties[legacyKey] !== undefined &&
properties[key] !== properties[legacyKey]) {
throw new Error('Conflicting measured fix metadata');
}
const value = properties[key] === undefined ? properties[legacyKey] : properties[key];
if (value !== undefined && value !== null && (!Number.isFinite(value) || value < 0)) {
throw new Error('Invalid measured fix metadata');
}
return value;
}
function countCoordinates(feature) {
const geometry = feature.geometry;
if (geometry.type === 'Point') return 1;
if (geometry.type === 'Polygon') return geometry.coordinates[0].length;
return geometry.coordinates.length;
}
function normaliseFeature(feature) {
if (feature?.type !== 'Feature' || !feature.geometry) throw new Error('Invalid GeoJSON feature');
const properties = feature.properties ?? {};
if (typeof properties !== 'object' || Array.isArray(properties)) throw new Error('Invalid feature properties');
const gisType = Object.hasOwn(GIS_TYPES, properties.type) ? properties.type : null;
if (gisType && GIS_TYPES[gisType][0] !== feature.geometry.type) throw new Error('GIS feature type and geometry disagree');
const electricalRole = gisType === '33kv_radial' && Object.hasOwn(RADIAL_NAMES, properties.role);
const navigationRole = electricalRole ? undefined : properties.role;
const role = properties.satnavRole ?? navigationRole ?? defaultRole[feature.geometry.type];
if (!roles.has(role)) throw new Error('Unsupported feature role or geometry');
if (properties.satnavRole != null && navigationRole != null && properties.satnavRole !== navigationRole) {
throw new Error('Conflicting planned and measured feature roles');
}
// The existing validator handles bounds, 2D coordinates, ring closure and track arrays.
// A single received fix is still measured even when it has no adjacent line segment.
const baseRole = role === 'walked-fix' ? 'waypoint' : role;
const [result] = normaliseGeoJSON({
...feature,
properties: {...properties, satnavRole: baseRole},
}).features;
if (Number.isFinite(feature.id)) result.id = feature.id;
result.properties.satnavRole = role;
if (gisType && !['walked-fix', 'walked-track'].includes(role)) {
result.properties.type = gisType;
const radial = electricalRole ? properties.role : properties.gisRole;
if (gisType === '33kv_radial' && Object.hasOwn(RADIAL_NAMES, radial)) result.properties.gisRole = radial;
if (!result.properties.name && ['poi', 'private_sub'].includes(gisType) && typeof properties.selected_substation_name === 'string') {
result.properties.name = properties.selected_substation_name.trim().slice(0, 200);
}
}
if (properties.gisReferenceOnly === true) result.properties.gisReferenceOnly = true;
if (role === 'walked-fix') {
const timestamp = sampleProperty(properties, 'timestampMs', 'timestamp');
const accuracy = sampleProperty(properties, 'accuracyM', 'accuracy');
if (timestamp !== undefined) result.properties.timestampMs = timestamp;
if (accuracy !== undefined) result.properties.accuracyM = accuracy;
}
if ((role === 'walked-fix' || role === 'waypoint') && properties.order !== undefined) {
if (!Number.isSafeInteger(properties.order) || properties.order < 0) throw new Error('Invalid point order');
result.properties.order = properties.order;
}
return result;
}
function validatePointOrder(features, role) {
const points = features.filter(feature => feature.properties.satnavRole === role);
if (!points.some(feature => feature.properties.order !== undefined)) return;
const ordered = [...points].sort((a, b) => a.properties.order - b.properties.order);
if (ordered.some((feature, index) => feature.properties.order !== index)) throw new Error('Invalid point order');
if (role === 'walked-fix') {
let previous = -Infinity;
for (const feature of ordered) {
const time = feature.properties.timestampMs;
if (time == null) continue;
if (time < previous) throw new Error('Measured fix times are out of order');
previous = time;
}
}
let index = 0;
for (let i = 0; i < features.length; i++) {
if (features[i].properties.satnavRole === role) features[i] = ordered[index++];
}
}
function validateMeasuredOrder(features) {
if (!features.some(feature => feature.properties.satnavRole === 'walked-track')) {
validatePointOrder(features, 'walked-fix');
return;
}
// The first V3 exporter counted all samples; its successor counted isolated fixes.
// Both encodings retain segment order in the FeatureCollection.
let sampleIndex = 0;
let singletonIndex = 0;
let globalOrder = true;
let singletonOrder = true;
for (const {geometry, properties} of features) {
if (properties.satnavRole === 'walked-track') sampleIndex += geometry.coordinates.length;
if (properties.satnavRole !== 'walked-fix') continue;
if (properties.order !== undefined) {
globalOrder = globalOrder && properties.order === sampleIndex;
singletonOrder = singletonOrder && properties.order === singletonIndex;
if (!globalOrder && !singletonOrder) throw new Error('Invalid measured sample order');
}
sampleIndex++;
singletonIndex++;
}
}
export function readSurveyLayout(input) {
const data = typeof input === 'string' ? JSON.parse(input) : input;
if (data?.schema === 'ventus.gis-route.v1') return fromGisSnapshot(data);
if (data?.crs != null && !geographicReferences.has(data.crs?.properties?.name)) {
throw new Error('Reproject the layout to WGS84 longitude and latitude before importing');
}
const features = featuresOf(data);
// SV02 pins and SV06 recorded fixes have independent limits. The V3 exporter
// can include both, the planned line repeating the pins, and a closed perimeter.
if (!Array.isArray(features) || features.length > 4 * MAX_COORDINATES) throw new Error('GeoJSON feature limit exceeded');
const ids = new Set();
const counts = new Map();
const result = features.map(feature => {
const clean = normaliseFeature(feature);
const role = clean.properties.satnavRole;
const group = role === 'walked-fix' ? 'walked-track' : role;
const count = (counts.get(group) ?? 0) + countCoordinates(clean);
if (count > MAX_COORDINATES) throw new Error('GeoJSON limit is 20,000 coordinates per layer');
counts.set(group, count);
if (clean.id !== undefined && ids.has(clean.id)) throw new Error('Duplicate GeoJSON feature ID');
if (clean.id !== undefined) ids.add(clean.id);
return clean;
});
validatePointOrder(result, 'waypoint');
validateMeasuredOrder(result);
return {type: 'FeatureCollection', features: result};
}
// Only explicitly planned geometry can replace the route in the map editor.
export function editableCoordinates(feature) {
const clean = normaliseFeature(feature);
if (clean.properties.gisReferenceOnly) return null;
switch (clean.properties.satnavRole) {
case 'waypoint': return [clean.geometry.coordinates];
case 'planned-route': return clean.geometry.coordinates;
case 'perimeter': return clean.geometry.coordinates[0].slice(0, -1);
default: return null;
}
}Interchange Test
A test in the survey folder of GridAtlas that checks Interchange, using EPSG:27700. It is built from the legacy fix helper (`legacyFix`).
testgridatlas / tools/satnav/survey/interchange.test.mjs · lines 1–103 of 103 · Entry point · pattern feature (shared by 12 files)
- What it does
- It tests its inputs. Defines feature, collection, legacyFix. Uses libraries node:assert/strict, node:test.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Inputs & outputs
- Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Defines `feature`, `collection` and `legacyFix`.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/satnav/survey · test
- Uses
- Interchange (import), node:assert/strict, node:test
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- feature, collection, legacyFix
- Defines here
- feature, collection, legacyFix
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/survey/interchange.test.mjs:1-103 · blob e17042503bb6cb26e235d48a0201f9943598857e · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import assert from 'node:assert/strict';
import test from 'node:test';
import {editableCoordinates, readSurveyLayout} from './interchange.mjs';
const a = [-0.1, 51.50], b = [-0.11, 51.51], c = [-0.10, 51.51];
const feature = (type, coordinates, properties = {}) => ({type: 'Feature', geometry: {type, coordinates}, properties});
const collection = (...features) => ({type: 'FeatureCollection', features});
const legacyFix = (point, order, timestamp) => feature('Point', point, {role: 'walked-fix', accuracy: 3, timestamp, order});
test('legacy GPS fix roundtrips as a single measured sample, separate from editable pins', () => {
const data = {...collection(legacyFix(a, 0, 10500), feature('Point', b, {role: 'waypoint', order: 0})), schema:'ventus.satnav.geojson.v1'};
const parsed = readSurveyLayout(data);
assert.deepEqual(parsed.features[0].properties, {satnavRole:'walked-fix', accuracyM:3, timestampMs:10500, order:0});
assert.equal(editableCoordinates(parsed.features[0]), null);
assert.deepEqual(editableCoordinates(parsed.features[1]), [b]);
assert.deepEqual(readSurveyLayout(JSON.stringify(parsed)), parsed);
});
test('canonical recorded lines and singleton fixes remain separate across a recording break', () => {
const data = collection(
feature('LineString', [a,b], {satnavRole:'planned-route'}),
feature('LineString', [b,c], {satnavRole:'walked-track', accuracyM:[2,5], timestampMs:[27000,28000]}),
feature('Point', a, {satnavRole:'walked-fix', accuracyM:7, timestampMs:45000}),
);
const actual = readSurveyLayout(JSON.stringify(data));
assert.deepEqual(actual, data);
assert.deepEqual(actual.features.map(editableCoordinates), [[a,b], null, null]);
});
test('singleton track with unknown sample metadata keeps it absent or explicitly null', () => {
const data=collection(feature('Point',a,{satnavRole:'walked-fix', timestampMs:null}));
assert.deepEqual(readSurveyLayout(data),data);
});
test('editing accepts only line, perimeter and waypoint roles, preserving a separate source', () => {
const polygon = feature('Polygon', [[a,b,c,a]], {role:'perimeter', name:'Site perimeter'});
const vertices = editableCoordinates(polygon);
assert.deepEqual(vertices,[a,b,c]);
vertices[0][0]=0;
assert.deepEqual(polygon.geometry.coordinates,[[a,b,c,a]]);
assert.equal(editableCoordinates(feature('LineString',[a,b],{role:'walked-track'})),null);
assert.deepEqual(editableCoordinates(feature('LineString',[a,b])),[a,b]);
});
test('legacy explicit order controls pin sequence and measured time sequence', () => {
const ordered = readSurveyLayout(collection(
legacyFix(c,1,20000), feature('Point',b,{role:'waypoint',order:1}),
legacyFix(b,0,10000), feature('Point',a,{role:'waypoint',order:0}),
));
assert.deepEqual(ordered.features.map(f=>f.geometry.coordinates), [b,a,c,b]);
assert.throws(()=>readSurveyLayout(collection(legacyFix(a,0,200),legacyFix(b,1,100))),/time/);
assert.throws(()=>readSurveyLayout(collection(legacyFix(a,0,100),legacyFix(b,0,200))),/order/);
});
test('ambiguous role and metadata are rejected without interpreting measurements as designs', () => {
assert.throws(()=>readSurveyLayout(feature('Point',a,{role:'walked-fix',satnavRole:'waypoint'})),/Conflicting/);
assert.throws(()=>readSurveyLayout(feature('LineString',[a,b],{role:'walked-fix'})),/ROLE/);
assert.throws(()=>readSurveyLayout(feature('Point',a,{role:'unrecognised'})),/Unsupported/);
assert.throws(()=>readSurveyLayout(feature('Point',a,{role:'walked-fix',timestamp:100,timestampMs:200})),/Conflicting/);
assert.throws(()=>readSurveyLayout(feature('Point',a,{role:'walked-fix',accuracy:-1})),/metadata/);
});
test('read-only committed GIS SLD routes import without financial metadata', () => {
const geometry={type:'LineString',coordinates:[a,b]};
const snapshot={schema:'ventus.gis-route.v1',status:'available',committed:true,pins:[],route:{geometry},originalLengthKm:0.4};
const parsed = readSurveyLayout(snapshot);
assert.deepEqual(editableCoordinates(parsed.features[0]),[a,b]);
assert.equal(parsed.features[0].properties.originalLengthKm,undefined);
assert.throws(()=>readSurveyLayout({...snapshot,status:'editing'}),/UNAVAILABLE/);
});
test('cross-feature cap, geographic coordinates, ring and duplicate IDs are validated', () => {
const first=feature('Point',a), second=feature('Point',b);
const long=feature('LineString',Array.from({length:20000},()=>a));
assert.throws(()=>readSurveyLayout(collection(long,feature('LineString',[a,b]))),/20,000/);
assert.throws(()=>readSurveyLayout(collection({...first,id:1},{...second,id:1})),/Duplicate/);
assert.throws(()=>readSurveyLayout({...collection(first),crs:{properties:{name:'EPSG:27700'}}}),/WGS84/);
assert.throws(()=>readSurveyLayout(feature('Point',[40,91])),/WGS84/);
assert.throws(()=>readSurveyLayout(feature('Polygon',[[a,b,c,b]])),/CLOSED/);
});
test('V3 singleton order counts the preceding samples in retained track segments', () => {
const line = feature('LineString',[a,b],{satnavRole:'walked-track',role:'walked-track',timestampMs:[10,20],accuracyM:[3,4]});
const point = feature('Point', c, {satnavRole:'walked-fix',role:'walked-fix',timestamp:30,timestampMs:30,accuracy:2,accuracyM:2,order:2});
const result=readSurveyLayout(collection(line,point));
assert.equal(result.features[1].properties.order,2);
assert.deepEqual(result.features.map(editableCoordinates),[null,null]);
assert.deepEqual(readSurveyLayout(JSON.stringify(result)),result);
const successorFile=collection(line,{...point,properties:{...point.properties,order:0}});
assert.equal(readSurveyLayout(successorFile).features[1].properties.order,0);
assert.throws(()=>readSurveyLayout(collection(line,{...point,properties:{...point.properties,order:1}})),/order/);
});
test('a full field recording can be imported together with its independent design', () => {
const points=Array.from({length:20000},(_,i)=>[a[0]-i/100000000,a[1]]);
const pins=points.map((p,i)=>feature('Point',p,{role:'waypoint',order:i}));
const design=feature('LineString',points,{role:'planned-route'});
const trace=feature('LineString',points,{satnavRole:'walked-track'});
const combined=readSurveyLayout(collection(...pins,design,trace));
assert.equal(combined.features.length,20002);
assert.equal(editableCoordinates(combined.features.at(-1)),null);
assert.throws(()=>readSurveyLayout(collection(trace,legacyFix(a,0,45000))),/20,000/);
});Model
A JavaScript module in the survey folder of GridAtlas that tracks feature (`trackFeature`) and creates field survey (`createFieldSurvey`). It tracks feature (`trackFeature`) and creates field survey (`createFieldSurvey`).
transformgridatlas / tools/satnav/survey/model.mjs · lines 1–131 of 131 · pattern resume (shared by 6 files)
- What it does
- It calculates its inputs. Defines 14 functions or classes, including feature, trackFeature, coordinate, createFieldSurvey, start.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- Used directly by 1 file: Model Test (gridatlas). Reached from 1 other entry point, including GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Its `createFieldSurvey` function gives survey session with recorded distance, track features, perimeter and role-labelled GeoJSON export from Fix-quality classifier, distance function, timestamped GPS fixes and planned WGS84 pins (VEDIC: conduct field survey).
- Why it matters
- Checked by Model Test.
- Application
- gridatlas · tools/satnav/survey · JavaScript module
- VEDIC
- CONDUCT FIELD SURVEY (GG2050-VEDIC-000099): SatNav · Location and navigation data. Fix-quality classifier, distance function, timestamped GPS fixes and planned WGS84 pins → Survey session with recorded distance, track features, perimeter and role-labelled GeoJSON export.
- Uses
- GeoJSON (import), Perimeter (import), Recorder (import)
- Used by
- imported by Model Test (import)
- Produces
- createFieldSurvey
- Defines here
- feature, trackFeature, coordinate, createFieldSurvey, start, pause, resume, stop, ingest, close, reopen, measuredFeatures, mapData, exportData
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/survey/model.mjs:1-131 · blob ed63511b44c96d6c460cec0c2480b09d0d0f6c5b · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import { normaliseGeoJSON } from '../interchange/geojson.mjs';
import { buildPerimeter } from '../perimeter/perimeter.mjs';
import { createTrackRecorder } from '../track/recorder.mjs';
const pointLimit = 20_000;
const maxGapMs = 10_000;
function feature(id, role, geometry, properties = {}) {
return { type: 'Feature', id, geometry, properties: { satnavRole: role, ...properties } };
}
function trackFeature(segment, index) {
const id = 'measured-' + (index + 1);
const coordinate = fix => [fix.longitude, fix.latitude];
if (segment.length === 1) {
const [fix] = segment;
return feature(id, 'walked-fix', { type: 'Point', coordinates: coordinate(fix) }, {
accuracyM: fix.accuracyM, timestampMs: fix.timestampMs,
});
}
return feature(id, 'walked-track', { type: 'LineString', coordinates: segment.map(coordinate) }, {
accuracyM: segment.map(fix => fix.accuracyM),
timestampMs: segment.map(fix => fix.timestampMs),
});
}
export function createFieldSurvey({ fixQuality, distanceKm }) {
let recorder = null;
let status = 'idle';
let pointCount = 0;
let distanceM = 0;
let previousFix = null;
let lastTimestamp = -Infinity;
const finishedSegments = [];
let perimeter = null;
function start() {
if (recorder || pointCount >= pointLimit) return false;
recorder = createTrackRecorder({ fixQuality, maxGapMs, maxPoints: pointLimit - pointCount });
recorder.start();
status = 'recording';
previousFix = null;
return true;
}
function pause() {
if (!recorder?.pause()) return false;
previousFix = null;
status = 'paused';
return true;
}
function resume() {
if (!recorder?.resume()) return false;
status = 'recording';
return true;
}
function stop() {
if (!recorder) return false;
recorder.stop();
finishedSegments.push(...recorder.snapshot().segments);
previousFix = null;
recorder = null;
status = 'stopped';
return true;
}
function ingest(fix, now = Date.now()) {
if (status !== 'recording') return false;
// A resumed watch may redeliver its last fix after the previous recording stopped.
if (Number.isFinite(fix?.timestampMs) && fix.timestampMs <= lastTimestamp && fixQuality(fix, now) === 'usable') return false;
const result = recorder.ingest(fix, now);
if (!result.accepted) {
if (result.reason !== 'nonmonotonic') previousFix = null;
return false;
}
if (previousFix && fix.timestampMs - previousFix.timestampMs <= maxGapMs) {
distanceM += distanceKm(previousFix.longitude, previousFix.latitude, fix.longitude, fix.latitude) * 1000;
}
previousFix = { longitude: fix.longitude, latitude: fix.latitude, timestampMs: fix.timestampMs };
lastTimestamp = fix.timestampMs;
pointCount++;
if (pointCount === pointLimit) stop();
return true;
}
function close(pins) {
const candidate = buildPerimeter(pins.map(pin => pin.coordinate), { distanceKm });
perimeter = candidate;
return perimeter;
}
function reopen() {
perimeter = null;
}
function measuredFeatures() {
const active = recorder ? recorder.snapshot().segments : [];
return finishedSegments.concat(active).map(trackFeature);
}
function mapData() {
const features = measuredFeatures();
if (perimeter) features.push(feature('boundary', 'perimeter', perimeter.polygon));
return { type: 'FeatureCollection', features };
}
function exportData(pins) {
const features = pins.map(pin => feature('pin-' + pin.id, 'waypoint', { type: 'Point', coordinates: pin.coordinate }));
if (pins.length >= 2) {
const line = perimeter?.plannedWalk ?? { type: 'LineString', coordinates: pins.map(pin => pin.coordinate) };
features.push(feature('design-line', 'planned-route', line));
}
features.push(...mapData().features);
// Each form has its own 20k capacity. A full recording can coexist with a full plan.
// The interchange adapter validates known roles. Its single-fix extension retains
// the measured role and recorder-validated metadata on genuinely isolated points.
const checked = features.map(f => f.properties.satnavRole === 'walked-fix' ? f : normaliseGeoJSON(f).features[0]);
return { type: 'FeatureCollection', features: checked };
}
return {
start, pause, resume, stop, ingest, close, reopen, mapData, exportData,
get status() { return status; },
get pointCount() { return pointCount; },
get distanceM() { return distanceM; },
get full() { return pointCount === pointLimit; },
get perimeter() { return perimeter; },
};
}Model Test
A test in the survey folder of GridAtlas that checks Model.
testgridatlas / tools/satnav/survey/model.test.mjs · lines 1–87 of 87 · Entry point
- What it does
- It tests its inputs. Defines create, fix, get. Uses libraries node:assert/strict, node:test.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Defines `create`, `fix` and `get`.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/satnav/survey · test
- Uses
- Model (import), node:assert/strict, node:test, ../vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/vendor/grid-distance-maths/src/geodesy.mjs, ../vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/nav/compass.mjs
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- create, fix, get
- Defines here
- create, fix, get
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/survey/model.test.mjs:1-87 · blob 5435ac930e49001b13c394e5db297bbf6eeafe20 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import assert from 'node:assert/strict';
import test from 'node:test';
import { distanceKm } from '../vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/vendor/grid-distance-maths/src/geodesy.mjs';
import { fixQuality } from '../vendor/9698781539e549deaa6ecaa4a2b34610c1f9fd29/nav/compass.mjs';
import { createFieldSurvey } from './model.mjs';
const create = () => createFieldSurvey({ fixQuality, distanceKm });
const fix = (longitude, timestampMs, accuracyM = 4) => ({ longitude, latitude: 51, timestampMs, accuracyM });
const pins = [[0,51], [0.001,51], [0.001,51.001]].map((coordinate, id) => ({ id, coordinate }));
const get = (data, role) => data.features.filter(f => f.properties.satnavRole === role);
test('a planned boundary closes once, produces measured units and reopens without changing the design pins', () => {
const survey = create();
const polygon = survey.close(pins);
assert.equal(polygon.polygon.coordinates[0].length, 4);
assert.ok(polygon.perimeterM > 300 && polygon.perimeterM < 325);
assert.ok(polygon.areaM2 > 3800 && polygon.areaM2 < 4000);
assert.equal(polygon.exceedsFollowerSegmentLimit, false);
const data = survey.exportData(pins);
assert.equal(get(data, 'waypoint').length, 3);
assert.deepEqual(get(data, 'perimeter')[0].geometry.coordinates[0], get(data, 'planned-route')[0].geometry.coordinates);
survey.reopen();
const open = survey.exportData(pins);
assert.equal(get(open, 'perimeter').length, 0);
assert.equal(get(open, 'planned-route')[0].geometry.coordinates.length, 3);
assert.equal(survey.pointCount, 0);
});
test('paused, poor, lost, stale and interrupted recordings preserve every genuine segment and its metadata', () => {
const survey = create();
assert.equal(survey.ingest(fix(0,900), 900), false);
survey.start();
survey.ingest(fix(0,1000), 1000);
survey.ingest(fix(0.001,1500,7), 1500);
survey.pause();
assert.equal(survey.ingest(fix(0.002,2000), 2000), false);
survey.resume();
survey.ingest(fix(0.5,2500), 2500);
assert.equal(survey.ingest(fix(0.51,3000,31), 3000), false);
survey.ingest(fix(0.52,3500), 3500);
assert.equal(survey.ingest(null, 3700), false);
survey.ingest(fix(0.53,4000), 4000);
assert.equal(survey.ingest(fix(0.54,4500), 17000), false);
survey.ingest(fix(0.55,17500), 17500);
survey.stop();
assert.equal(survey.ingest(fix(0.56,18000), 18000), false);
survey.start();
assert.equal(survey.ingest(fix(0.55,17500), 18000), false);
survey.ingest(fix(0.57,18500), 18500);
survey.ingest(fix(0.58,30000), 30000);
survey.stop();
const data = survey.exportData([]);
assert.equal(survey.pointCount, 8);
assert.equal(get(data, 'walked-track').length, 1);
assert.equal(get(data, 'walked-fix').length, 6);
assert.deepEqual(get(data, 'walked-track')[0].properties.timestampMs, [1000, 1500]);
assert.deepEqual(get(data, 'walked-track')[0].properties.accuracyM, [4, 7]);
assert.equal(get(data, 'walked-fix')[0].properties.timestampMs, 2500);
assert.equal(get(data, 'walked-fix')[0].properties.accuracyM, 4);
assert.equal(survey.distanceM, distanceKm(0, 51, 0.001, 51) * 1000);
assert.equal(get(data, 'waypoint').length, 0);
});
test('invalid rings do not change pins and long boundary legs are identified', () => {
const survey = create();
assert.throws(() => survey.close(pins.slice(0, 2)), /INVALID_VERTEX_COUNT/);
assert.throws(() => survey.close([pins[0], pins[1], pins[0]]), /INVALID_VERTEX_COUNT/);
const long = survey.close([pins[0], pins[1], { id: 7, coordinate: [0.02, 51.01] }]);
assert.equal(long.exceedsFollowerSegmentLimit, true);
});
test('20,000 accepted fixes remain exportable with a plan and repeated starts keep the previous data', () => {
const survey = create();
for (let session = 0; session < 2; session++) {
survey.start();
for (let i = 0; i < 10_000; i++) {
const t = 1 + i + session * 10_000;
survey.ingest(fix(i / 1_000_000, t), t);
}
survey.stop();
}
assert.equal(survey.full, true);
assert.equal(survey.start(), false);
const data = survey.exportData(pins);
assert.deepEqual(get(data, 'walked-track').map(f => f.geometry.coordinates.length), [10_000, 10_000]);
assert.equal(get(data, 'waypoint').length, 3);
});Recorder
A JavaScript module in the track folder of GridAtlas. It creates track recorder (`createTrackRecorder`) and is built from the snapshot step (`snapshot`) and the start step (`start`).
transformgridatlas / tools/satnav/track/recorder.mjs · lines 1–26 of 26 · pattern resume (shared by 6 files)
- What it does
- It calculates its inputs. Defines 7 functions or classes, including createTrackRecorder, snapshot, start, pause, resume.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- Used directly by 2 files: Model (gridatlas); Recorder Test (gridatlas). Reached from 2 other entry points, including GridAtlas PR File Size Guard Workflow (gridatlas); Model Test (gridatlas).
- What it achieves
- Session-only measured GPS recorder; inject pinned compass.fixQuality.
- Why it matters
- Imported by Model. Checked by Recorder Test.
- Application
- gridatlas · tools/satnav/track · JavaScript module
- VEDIC
- RECORD GPS TRACK (GG2050-VEDIC-000096): SatNav · Location and navigation data. Fix-quality classifier, timestamped WGS84 fixes with accuracy in metres, optional gap and point limits → Session recorder with lifecycle controls, accepted or rejected fixes and segmented snapshots.
- Uses
- none found
- Used by
- imported by Model (import), imported by Recorder Test (import)
- Produces
- createTrackRecorder
- Defines here
- createTrackRecorder, snapshot, start, pause, resume, stop, ingest
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/track/recorder.mjs:1-26 · blob e276d7ee32243b731eb4db1cdaf2f720da4c9dbc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
// Session-only measured GPS recorder; inject pinned compass.fixQuality.
// No browser GPS watch, storage, upload, interpolation or access inference.
// Pause, rejected quality and signal gaps create separate segments.
export function createTrackRecorder({fixQuality,maxGapMs=10000,maxPoints=20000}={}){
if(typeof fixQuality!=="function"||!Number.isFinite(maxGapMs)||maxGapMs<=0||!Number.isSafeInteger(maxPoints)||maxPoints<1)throw new TypeError("INVALID_TRACK_CONFIG");
let status="idle",segments=[],count=0,lastTimestamp=null,split=true,rejected=0;
const snapshot=()=>({schema:"ventus.satnav-track.v1",status,pointCount:count,rejected,segments:segments.map(s=>s.map(p=>({...p}))),kind:"measured_gps",accessStatus:"unverified"});
function start(){if(status!=="idle")return false;status="recording";return true;}
function pause(){if(status!=="recording")return false;status="paused";split=true;return true;}
function resume(){if(status!=="paused")return false;status="recording";split=true;return true;}
function stop(){if(!["recording","paused"].includes(status))return false;status="stopped";return true;}
function ingest(fix,now=Date.now()){
if(status!=="recording")return {accepted:false,reason:status};
if(count>=maxPoints){stop();return {accepted:false,reason:"capacity"};}
const quality=fixQuality(fix,now);
if(quality!=="usable"){rejected++;split=true;return {accepted:false,reason:quality};}
const {longitude,latitude,accuracyM,timestampMs}=fix;
if(![longitude,latitude,accuracyM,timestampMs,now].every(Number.isFinite)||Math.abs(longitude)>180||Math.abs(latitude)>90||accuracyM<0||timestampMs>now){rejected++;split=true;return {accepted:false,reason:"invalid"};}
if(lastTimestamp!==null&×tampMs<=lastTimestamp){rejected++;return {accepted:false,reason:"nonmonotonic"};}
if(split||lastTimestamp===null||timestampMs-lastTimestamp>maxGapMs)segments.push([]);
segments[segments.length-1].push({longitude,latitude,accuracyM,timestampMs});count++;lastTimestamp=timestampMs;split=false;
if(count===maxPoints)stop();
return {accepted:true,reason:"usable"};
}
return Object.freeze({start,pause,resume,stop,ingest,snapshot});
}Recorder Test
A test in the track folder of GridAtlas that checks Recorder. It runs tests (`runTests`) and is built from the fix quality helper (`fixQuality`) and the fix step (`fix`).
testgridatlas / tools/satnav/track/recorder.test.mjs · lines 1–21 of 21 · Entry point · pattern fixQuality (shared by 2 files)
- What it does
- It tests its inputs. Defines runTests, fixQuality, fix. Uses libraries node:assert/strict.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'satnav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- Its `fixQuality` function gives location fix quality from longitude latitude accuracy timestamp fix and optional reference time ms (VEDIC: check location fix).
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · tools/satnav/track · test
- VEDIC
- CHECK LOCATION FIX (GG2050-VEDIC-000062): SatNav · Location and navigation data. longitude_latitude_accuracy_timestamp_fix, reference_time_ms_optional → location_fix_quality
- Uses
- Recorder (import), node:assert/strict
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- runTests, fixQuality, fix
- Defines here
- runTests, fixQuality, fix
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/satnav/track/recorder.test.mjs:1-21 · blob 4a74bfbea5297893f4e580ac05ec03ecd9142ab9 · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import assert from 'node:assert/strict';
import {createTrackRecorder} from './recorder.mjs';
function runTests(createTrackRecorder,assert){
const fixQuality=(f,n)=>!f?"missing":!Number.isFinite(f.longitude)?"invalid":n-f.timestampMs<0||n-f.timestampMs>10000?"stale":f.accuracyM>30?"poor":"usable";
const fix=(t,accuracyM=5,longitude=-0.3)=>({longitude,latitude:51.5,accuracyM,timestampMs:t});
const tests=[
["explicit opt-in",()=>{const r=createTrackRecorder({fixQuality});assert(!r.ingest(fix(1),1).accepted);assert(r.start());assert(r.ingest(fix(2),2).accepted);assert(r.snapshot().pointCount===1)}],
["pause/resume gap",()=>{const r=createTrackRecorder({fixQuality});r.start();r.ingest(fix(1),1);r.pause();assert(!r.ingest(fix(2),2).accepted);r.resume();r.ingest(fix(3),3);assert(r.snapshot().segments.length===2)}],
["poor and stale fixes split",()=>{const r=createTrackRecorder({fixQuality});r.start();r.ingest(fix(1),1);assert(r.ingest(fix(2,31),2).reason==="poor");assert(r.ingest(fix(3),20000).reason==="stale");r.ingest(fix(4),4);assert(r.snapshot().segments.length===2);assert(r.snapshot().rejected===2)}],
["missing and invalid fixes",()=>{const r=createTrackRecorder({fixQuality});r.start();assert(!r.ingest(null,1).accepted);assert(!r.ingest(fix(2,5,181),2).accepted);assert(r.snapshot().pointCount===0)}],
["signal gap",()=>{const r=createTrackRecorder({fixQuality});r.start();r.ingest(fix(1),1);r.ingest(fix(10002),10002);assert(r.snapshot().segments.length===2)}],
["duplicate or out-of-order",()=>{const r=createTrackRecorder({fixQuality});r.start();r.ingest(fix(2),2);assert(!r.ingest(fix(2),2).accepted);assert(!r.ingest(fix(1),2).accepted);assert(r.snapshot().pointCount===1)}],
["stop rejects later callbacks",()=>{const r=createTrackRecorder({fixQuality});r.start();r.ingest(fix(1),1);r.stop();assert(!r.ingest(fix(2),2).accepted);assert(!r.resume());assert(!r.start());assert(r.snapshot().status==="stopped")}],
["immutable snapshot boundary and exact measured coordinates",()=>{const r=createTrackRecorder({fixQuality});r.start();const f=fix(1);r.ingest(f,1);f.longitude=0;const s=r.snapshot();s.segments[0][0].longitude=1;assert(r.snapshot().segments[0][0].longitude===-0.3)}],
["capacity bound",()=>{const r=createTrackRecorder({fixQuality,maxPoints:2});r.start();r.ingest(fix(1),1);r.ingest(fix(2),2);assert(r.snapshot().status==="stopped");assert(!r.ingest(fix(3),3).accepted);assert(r.snapshot().pointCount===2)}],
["independent recorder sessions",()=>{const a=createTrackRecorder({fixQuality}),b=createTrackRecorder({fixQuality});a.start();a.ingest(fix(1),1);assert(b.snapshot().pointCount===0)}]
];
for(const [name,test] of tests){try{test()}catch(e){throw Error(name+": "+e.message)}}
return tests.map(([name])=>name);
}
console.log(runTests(createTrackRecorder,assert).length+' tests passed');