Skip to content

a checker for the geojson format. goes beyond a schema, checking semantics and producing character-level warnings.

License

Notifications You must be signed in to change notification settings

placemark/check-geojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 18, 2025
5701f8f Â· Feb 18, 2025

History

84 Commits
Oct 31, 2022
Feb 18, 2025
May 23, 2022
Feb 18, 2025
Feb 18, 2025
May 19, 2021
Oct 15, 2021
Mar 19, 2022
May 23, 2022
May 20, 2021
Apr 28, 2022
Apr 25, 2022
May 19, 2021
Feb 18, 2025
Feb 18, 2025
Feb 18, 2025
Feb 18, 2025
Mar 19, 2022
Mar 19, 2022

Repository files navigation

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.

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