Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on May 29, 2024. It is now read-only.
/geojsonhintPublic archive

IMPORTANT: This repo will be archived. Use @placemarkio/check-geojson instead

License

NotificationsYou must be signed in to change notification settings

mapbox/geojsonhint

Repository files navigation

Build StatusCoverage Status

geojsonhint: complete, fast, standards-based validation for geojson

Important: development of geojsonhint is currently paused. Until development restarts, please refrain from adding non-critical issues or PRs.

Alint tool for theGeoJSONstandard. geojsonhint is writtento the standard, with no missing or additionalopinions about structure.

Thanks tojsonlint-lines, GeoJSON that is also not validJSONcan return informative, line-oriented parsing errors.

Specification

The basis of this tool is the publishedGeoJSON specification.

API

errors = geojsonhint.hint(string or object, options)

Lint a file, given as a string or object. This call detects all aberrations fromthe GeoJSON standards and returns them as an array of errors. An example of the output:

[{"message":"\"features\" property should be an array, but is an object instead","line":1}]

The options argument is optional. It has these options:

noDuplicateMembers.

By default, geojsonhint will treat repeated properties as an error: you canset noDuplicateMembers to false to allow them. For instance:

geojsonhint.hint('{"type":"invalid","type":"Feature","properties":{},"geometry":null}',{noDuplicateMembers:false});

The repeatedtype property in this input will be ignored with the option,and flagged without it.

precisionWarning.

GeoJSONnow recommends six decimal places of accuracyfor coordinates (Section 11.2). This option adds a warning message when coordinatescontain over 6 decimal places of accuracy, up to 10 coordinates before the warningmessage is truncated for performance.

geojsonhint.hint('{ "type": "Point", "coordinates": [100.0000000001, 5.0000000001] }',{precisionWarning:false});

With this option enabled, geojsonhint will produce these warnings:

[{line:1,level:'message',message:'precision of coordinates should be reduced'},{line:1,level:'message',message:'precision of coordinates should be reduced'}]

Without this option, this input will pass without errors.

ignoreRightHandRule.

GeoJSON specification defined that linear rings must follow right-hand rule, but also says that for backward compatibility reasons parsers should not rejects polygons wiht incorrect winding order. For that kind of situations geojsonhint has an optionignoreRightHandRule which isfalse by default. Setting this option totrue will cause geojsonhint to skip right-hand rule validation.

geojsonhint.hint(geojsonWithIncorrectWindingOrder,{ignoreRightHandRule:true});

with this option enabled, geojsonhint will not validate winding order.

Line Numbers

Note that the GeoJSON can be given as astring or as an object. Here's howto choose which input to use:

  • string inputs receiveline numbers for each error. These make errorseasier to track down if the GeoJSON is hand-written.
  • object inputs don't have line numbers but are evaluated faster, by up to 10x.GeoJSONHint isvery fast already so unless you have identified it as abottleneck in your application, don'tprematurely optimize basedon this fact.

If you're really trying to save space and don't care about JSON validity errors -only GeoJSON errors - you canrequire('geojsonhint/lib/object') to get a versionof this library that bypasses jsonlint-lines and provides only the objectinterface.

use it

npm (node.js, browserify, webpack, etc)

npm install --save @mapbox/geojsonhint

CDN / script tag

Hit this URL to resolve to the latest pinned version.

https://unpkg.com/@mapbox/geojsonhint@latest/geojsonhint.js

As a command-line utility

Install:

npm install -g @mapbox/geojsonhint
➟ geojsonhintUsage: geojsonhint FILE.geojsonOptions:  --json  output json-formatted data for hints
➟ geojsonhint test.geojsonline 9, each element in a position must be a number

Development

  • Tests:npm test
  • Building the browser version:npm run build

See Also

About

IMPORTANT: This repo will be archived. Use @placemarkio/check-geojson instead

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp