geojson_db

0.3.4 • Public • Published

GeoJSON DB

GeoJSON DB is a high performance npm package designed to facilitate fast spatial queries on GeoJSON files. It currently supports .geojsonl (line-limited GeoJSON features), .csv and .tsv files. The files can be compressed with .br, .gz or uncompressed. Due to the in-memory architecture, make sure you have enough memory to load the full uncompressed file.

Example Usage

import Geofile from 'geojson_db';

let file = new Geofile('features.geojsonl.gz');

let bbox = [7, 50, 8, 51];
for (let feature of file.find(bbox)) {
   feature = JSON.parse(feature);
   console.log(feature);
}

Notice, that the raw file is indexed and that the results are lines from this raw file as string. If it is a GeoJSONL file, you'll get JSON strings. For CSV or TSV you get single CSV/TSV lines as string.

You can also define options:

let file = new Geofile('features.csv.gz', {
   separator: ';', // field seperator for CSV / TSV files - default: "," / "\t"
   colX: 3, // column index of x values - default: 0
   colY: 4, // column index of y values - default: 1
   skipLines: 1,  // number of lines to skip, e.g. header line - default: 0
});

Installation

GeoJSON DB requires a supported version of Node and Rust.

To install the project using npm, navigate to the project directory, and run:

$ npm install

This command installs the project and its dependencies and also initiates the build.

Build

To only execute the build process for an already installed project, run:

$ npm run build

This command uses the cargo-cp-artifact utility to perform the Rust build and subsequently copies the built library into ./index.node.

Available Scripts

In the project directory, you can run:

  • npm run install - Installs the project, including running npm run build.

  • npm run build - Builds the Node addon (index.node) from source.

  • npm run build-debug - Alias for npm run build.

  • npm run build-release - Equivalent to npm run build but builds the Rust Code with release profile. Although release builds compile slower, the resulting binaries run faster.

  • npm run test - Executes the unit tests using cargo test. To learn more about adding tests to your Rust code, refer to the Rust book.

Documentation and Additional Learning Resources

Package Sidebar

Install

npm i geojson_db

Weekly Downloads

0

Version

0.3.4

License

MIT

Unpacked Size

49.7 kB

Total Files

14

Last publish

Collaborators

  • michaelkreil