0.5.0 β€’ Published 4 months ago

gis-tools-ts v0.5.0

Weekly downloads
-
License
See LICENSE file.
Repository
github
Last release
4 months ago

About

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

Features

Notable features of GIS-Tools are:

  • πŸ”— Lightweight, fast, and memory efficient. no_std builds for Rust. Tree-shaking for Typescript.
  • πŸ—ΊοΈ Full toolkit support for WGS84, Web Mercator, and S2 projections.
  • 🌱 A large list of projections can be converted to/from one of the above 3 via Transformers.
  • πŸ“¦ Build Vector Tiles, Raster Tiles, and Gridded Data Tiles. Vector supports 3 output formats (Mapbox Vector Tile, Open S2 Tiles, and Flat Open S2 Tiles).
  • βœ… Most data structures support all projections, but primarily focus the big 3 states above. Also handle large data sets through working with the filesystem and mmap buffers.
  • πŸ“– Contains 23 native GIS readers. The list of readers are: CSV, GBFS, GeoTIFF, GPX, GRIB2, GTFS, JPEG and JPEG2000, (Geo|S2)JSON, LineDelimted GeoJSON, GeoJSON Text Sequences, LAS, LAZ, NadGrids, NetCDF, OSM, (S2)PMTiles, Shapefiles, raster and vector tiles, WKT, and XML.
  • 🦺 Secure code where the only external dependency is sharp for local image processing, otherwise all code is written internally by Open S2 in Typescript or Rust.
  • 🧲 Full suite of tools for points, lines, polygons, greater-circle-arcs, predicates, and more.
  • 🌌 Space specific tools for planets and satellite orbits.

Goals

Making GIS data easy to parse and work with. One of the biggest issues in GIS right now is how segmented various niche tools are. The other issue is how most solutions to read GIS data are half baked, deprecated, or partially parse results that need to be transformed one more time to use them.

So this tool exists to make GIS tools simple to use, various data fast to parse, and transformed to usable projections without having to worry about the details.

Lastly the goal is for all code to be accessible to both the browser and locally. An example was the shapefile reader where it can pull from online data or handle extremely large data as well.

Install

# NPM
npm install gis-tools-ts
# PNPM
pnpm add gis-tools-ts
# Yarn
yarn add gis-tools-ts
# Bun
bun add gis-tools-ts
# Deno
deno install gis-tools-ts

# Cargo
cargo add gis-tools

Components

πŸ’‘ NOTE: The sizes are estimates and can change based on how you use them. Click the module link for documentation and more precise guides on file cost.

Converters

ModuleSize Description
toJSONTo JSON BadgeConvert any Reader to JSON data.
toTilesFT BadgeConvert any Reader to vector and/or raster tiles.

Data Stores

ModuleSize Description
externalSortES BadgeSort large files with uint64 keys
kvKV BadgeKey-Value store that works in the browser and the filesystem.
multiMapMM BadgeMulti-map that works in the browser and the filesystem.
vectorVec BadgeVector store that works in the browser and the filesystem.

Data Structures

ModuleSize Description
cacheCache BadgeA KV cache for values with a max size. Least used dropped first.
pointGridPG BadgePoint grid tiling for number or raster data.
pointClusterPC BadgePoint cluster tool with indexing.
pointIndexPI BadgePoint indexing with range/radius queries.
pointIndexFastPIF BadgeFaster point indexing with range/radius queries.
priorityQueuePQ BadgeA priority queue.
tileTile BadgeA tile/layer management tool for features.

Geometry

ModuleSize Description
anglesAngle BadgeSpherical geodetic angle methods.
bboxBBOX BadgeBounding box creation/manipulation.
idID BadgeID tools for S2 and WM.
lonlatLonLat BadgeLongitude/Latitude convienience methods.
predicatesPred BadgeReliability predicates for 2D and 3D orientation geometry.
s2S2 BadgeS2 geometry convienience methods.
toolsTools BadgeGeometry manipulation tools.
wmWM BadgeWeb Mercator (WM) geometry convienience methods.

PROJ4

ModuleSize Description
mgrsMGRS BadgeMilitary Grid Reference System (MGRS) converter.
projectionsProj BadgeSupports a large list of projections to be used by transformers.
transformerTrans BadgeTool for transforming coordinates from one projection to another.

Readers

Most readers are parsers that take ReaderInputs as an input. This is to ensure both browser and file inputs are supported. You can learn more about readers here.

ModuleSize Description
jpegJPEG BadgeRead/parse JPEG data.
jpeg2000JPEG2 BadgeRead/parse JPEG 2000 data.
lanczosLanc BadgeApply a Lanczos filter that downsamples an image.
csvCSV BadgeCSV data reader with options on parsing.
gbfsGBFS BadgeGeneral Bikeshare Feed Specification reader.
geotiffGTiff BadgeGeotiff image reader with projection support.
gpxGPX BadgeGPX (xml based) data reader.
grib2grib2 BadgeGRIB 2 data reader.
gtfsgtfs BadgeGeneral Transit Feed Specification. Both Static and Realtime.
jsonJSON BadgeJSON data reader with line delimiter support.
lasLAS BadgeLAS data reader.
lazLAZ BadgeLASzipped data reader.
nadgridNGrid BadgeNAD Grid data reader.
netcdfNetCDF BadgeNetCDF data reader.
osmOSM BadgeOpenStreetMap PBF data reader
pmtilesPMT Badge(S2)PMTiles data reader.
protobufProto BadgeProtobuf data reader/writer.
shapefileShape BadgeShapefile data reader supporting DBF and projections (PRJ).
tileReaderTR BadgeTile data reader, usually from a local input folder.
wktwkt BadgeWell Known Text data reader.
xmlXML BadgeXML data reader.

Space

ModuleSize Description
planetsPlanet BadgeCollection of planet constants with observation tools.
satelliteSAT BadgeSatellite Orbit Class from TLE data

Tools

ModuleSize Description
delaunatorDEL BadgeDelaunay triangulation of 2D points.
interpolatorsINT BadgeInterpolate values from points and weights.
orthodromeORT BadgeFind shortest path between two points or point on path.
polylabelPOL BadgeFind the labels for vector polygons

Writers

ModuleSize Description
pmtilesWriterPMTW BadgeWrite (S2)PMTiles data.
tileWriterTW BadgeWrite (S2)Tiles data. Supports time series as well.

Utils

ModuleSize Description
polyfillsPF BadgeCollection of polyfills that might add value for the browser.
compressionCMP Badgecompression/decompression convenience methods.

Development

Requirements

You need the tool tarpaulin to generate the coverage report. Install it using the following command:

cargo install cargo-tarpaulin

The bacon coverage tool is used to generate the coverage report. To utilize the pycobertura package for a prettier coverage report, install it using the following command:

pip install pycobertura

Running Tests

To run the tests, use the following command:

# TYPESCRIPT
## basic test
bun run test
## live testing
bun run test:dev

# RUST
## basic test
cargo test
# live testing
bacon test

Generating Coverage Report

To generate the coverage report, use the following command:

# install
cargo +stable install cargo-llvm-cov --locked
# run test
cargo llvm-cov
# bacon
bacon coverage # or type `l` inside the tool

# output lcov
cargo llvm-cov --lcov --output-path coverage/lcov.info

Using Tokei

cargo install tokei