mirror of
https://github.com/flatgeobuf/flatgeobuf.git
synced 2025-12-08 19:06:03 +00:00
16 lines
621 B
JavaScript
16 lines
621 B
JavaScript
import { readFileSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import * as url from 'node:url';
|
|
import { deserialize, serialize } from 'flatgeobuf/lib/mjs/geojson.js';
|
|
|
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
const data = readFileSync(path.join(__dirname, '../../test/data/countries.geojson'));
|
|
const jsonData = JSON.parse(data);
|
|
// NOTE: be aware that TS/JS implementation creates files with no spatial index
|
|
const serializedFeatures = serialize(jsonData);
|
|
|
|
const reDeserializedData = deserialize(new Uint8Array(serializedFeatures));
|
|
|
|
console.log(JSON.stringify(reDeserializedData));
|