Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@placemarkio/check-geojson

placemark83.2kMIT0.1.14TypeScript support: included

A spiritual successor to geojsonhint, which is no longer maintained.

readme

check-geojson

A spiritual successor to geojsonhint, which is no longer maintained.

check-geojson is a parser and validator for GeoJSON strings. It is tailored to the use cases of validating user-generated GeoJSON content, or troubleshooting GeoJSON that you've received.

Note: the API is not yet stable.

📕 API Documentation

Main differences from geojsonhint

  • Actively maintained
  • Written in TypeScript and includes types
  • Uses momoa to parse JSON instead of a homemade parser. This is probably the biggest one. jsonlint-lines was a hack, which I created because I could not find a single parser that actually parsed JSON and gave line numbers for values. momoa is much better than that hack, and using it makes line-level errors much cleaner.

Unlike geojsonhint, this checker only produces errors, not warnings. So things that geojsonhint would warn about, like:

  • excessive coordinate precision
  • right-hand rule compliance

This does not check for. Additionally, the crs member is ignored by this tool: as of the latest GeoJSON specification, this is not used.

We're using the same test fixtures as geojsonhint as a starter.

Install

pnpm add @placemarkio/check-geojson
yarn add @placemarkio/check-geojson

Usage

import { check } from "@placemarkio/check-geojson"

let geojsonObject;
try {
  geojsonObject = check('… geojson string …')
} catch (e) {
  /// e.issues
}

If your GeoJSON is already an object, you will need to convert it to a string first. geojson-check will re-parse it. You should consider the performance penalty of this.

const issues = getIssues(JSON.stringify(geojsonObject));
if (issues.length > 0) {
  // ...
}

Maintainability Test Coverage

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.1.11 (2022-04-28)

0.1.10 (2022-04-13)

Bug Fixes

  • correct module entry point (455081a)

0.1.9 (2022-03-19)

Bug Fixes

  • Avoid downlevel iteration (48dc9f3)