This commit is contained in:
Raven Scott
2026-05-20 21:02:45 -04:00
parent 1f3f4b24a2
commit 14d0980b4f
734 changed files with 682 additions and 746 deletions
@@ -0,0 +1,28 @@
const SpatialIndex = require('../index.js')
const { setTimeout } = require('bare-timers')
async function main () {
const index = new SpatialIndex({
storageDir: './spatial-demo-storage'
})
await index.ready()
console.log('Spatial index ready')
// Simulate inserting locations
await index.insert('drone-1', 500, 600, { type: 'drone', battery: 87 })
await index.insert('vehicle-42', 1200, 800, { type: 'vehicle', speed: 45 })
const nearby = await index.rangeQuery(400, 500, 1000, 1000)
console.log('Nearby assets:', nearby.length)
const closest = await index.nearestNeighbor(600, 700, 2)
console.log('Closest:', closest.map(p => p.id))
// Keep alive for demo
await new Promise(r => setTimeout(r, 5000))
await index.close()
console.log('Demo complete')
}
main().catch(console.error)