-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
39 lines (28 loc) · 1.02 KB
/
test.js
File metadata and controls
39 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
import { readFileSync, writeFileSync } from 'node:fs';
import Geofile from './index.js';
console.log(Geofile);
console.time('open');
let file = new Geofile('./data/adresse.csv.br')
//let file = new Geofile('./testdata/points.csv.gz')
//let file = new Geofile('./testdata/polygons.geojsonl.br')
console.timeEnd('open');
console.log(file);
//let bbox = [13.324571, 52.513766, 13.345771, 52.524473];
//let bbox = [13.3, 52.5, 13.4, 52.6];
let bbox = [-180, -90, 180, 90];
//let bbox = [7, 49, 8, 50];
let count = 0;
console.time('iterate');
//for (let entry of file.find(bbox)) console.log(entry);
for (let entry of file.find(bbox)) count++;
console.timeEnd('iterate');
console.log(count);
/*
console.time('manual');
let data = readFileSync('data/points.geojsonl', 'utf8');
data = data.split('\n').filter(l => l.length > 0).map(l => JSON.parse(l));
console.timeEnd('manual');
console.log(data.length);
*/
//writeFileSync('test.geojson', JSON.stringify({ type: 'FeatureCollection', features: Array.from(file.find(bbox)) }));