npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geojson_db

v0.3.4

Published

A high-performance npm package for rapid spatial queries on GeoJSON files

Downloads

5

Readme

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