Created
November 20, 2023 13:33
-
-
Save ceoworks/faaab4ba9d8e4f901e4d287b7f2b3c12 to your computer and use it in GitHub Desktop.
Geojson validation does not throw erros on duplicate members
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // run with ts-node and there will be no errors. | |
| import { check } from "@placemarkio/check-geojson"; | |
| const geojsonHint = require("@mapbox/geojsonhint"); | |
| const testPolygon = { | |
| type: "Polygon", | |
| coordinates: [ | |
| [ | |
| [2, 1], | |
| [2, 1], | |
| [1, 2], | |
| [1, 2], | |
| [0, 0], | |
| [0, 0], | |
| [2, 1], | |
| [2, 1], | |
| ], | |
| ], | |
| }; | |
| try { | |
| const parseValue = check(JSON.stringify(testPolygon)); | |
| console.log("parseValue:", parseValue); | |
| } catch (e) { | |
| /// e.issues | |
| console.error(e); | |
| } | |
| const errors = geojsonHint.hint(JSON.stringify(testPolygon), { | |
| noDuplicateMembers: true, | |
| }); | |
| console.log("errors:", errors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment