{"id":22049049,"url":"https://github.com/konfirm/geojson","last_synced_at":"2026-05-30T22:00:31.629Z","repository":{"id":65700218,"uuid":"441099981","full_name":"konfirm/geojson","owner":"konfirm","description":"TypeScript-first GeoJSON validation, intersection, and geodesic distance — RFC 7946 compliant","archived":false,"fork":false,"pushed_at":"2026-05-30T20:14:41.000Z","size":378,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-05-30T21:19:31.307Z","etag":null,"topics":["distance","geodesy","geojson","geometry","gis","guard","haversine","intersection","rfc7946","typescript","validation","vincenty"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konfirm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-23T07:33:23.000Z","updated_at":"2026-05-30T20:14:45.000Z","dependencies_parsed_at":"2023-02-18T22:30:52.363Z","dependency_job_id":null,"html_url":"https://github.com/konfirm/geojson","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/konfirm/geojson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konfirm%2Fgeojson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konfirm%2Fgeojson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konfirm%2Fgeojson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konfirm%2Fgeojson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konfirm","download_url":"https://codeload.github.com/konfirm/geojson/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konfirm%2Fgeojson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33711018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distance","geodesy","geojson","geometry","gis","guard","haversine","intersection","rfc7946","typescript","validation","vincenty"],"created_at":"2024-11-30T14:14:06.883Z","updated_at":"2026-05-30T22:00:31.613Z","avatar_url":"https://github.com/konfirm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Release](https://github.com/konfirm/geojson/actions/workflows/release.yml/badge.svg)](https://github.com/konfirm/geojson/actions/workflows/release.yml)\n[![Tests](https://github.com/konfirm/geojson/actions/workflows/tests.yml/badge.svg)](https://github.com/konfirm/geojson/actions/workflows/tests.yml)\n\n# @konfirm/geojson\n\nGeoJSON validation, iteration, intersection and distance calculation.\n\n## API\n\n### Types\n\nAll [GeoJSON types](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1) are available as export\n\n| type               | descriptions                                                                                | note                                                                                                                                                                                                    |\n| ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Position           | A [GeoJSON Position](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1)           | `[Longitude, Latitude, Altitude?]`                                                                                                                                                                      |\n| Point              | A [GeoJSON Point](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2)              | The `coordinates` property is a `Position`                                                                                                                                                              |\n| MultiPoint         | A [GeoJSON MultiPoint](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.3)         | The `coordinates` property is an array of `Position`                                                                                                                                                    |\n| LineString         | A [GeoJSON LineString](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4)         | The `coordinates` property is an array of two or more `Position`                                                                                                                                        |\n| MultiLineString    | A [GeoJSON MultiLineString](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.5)    | The `coordinates` property is an array of`LineString` coordinates                                                                                                                                       |\n| Polygon            | A [GeoJSON Polygon](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6)            | The `coordinates` property is an array of \"LinearRings\" (closed `LineString` coordinates, where the first and last `Position` are identical)                                                            |\n| MultiPolygon       | A [GeoJSON MultiPolygon](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.7)       | The `coordinates` property is an array of `Polygon` coordinate arrays                                                                                                                                   |\n| GeometryCollection | A [GeoJSON GeometryCollection](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.8) | geometries is an array of Geometries (`Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`)                                                                                |\n| Feature            | A [GeoJSON Feature](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2)              | A spatially bounded 'Thing', consisting of a `geometry` property (`Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`, `GeometryCollection`) with additional `properties` |\n| FeatureCollection  | A [GeoJSON Collection](https://datatracker.ietf.org/doc/html/rfc7946#section-3.3)           | The `features` property is an array of `Feature` objects                                                                                                                                                |\n\n\n### Type Guards\n\nMost of the exported functionality is based on validation of GeoJSON objects, validating required and optional (if provided) properties. \nThe `isStrict*` variants of the type guards also validate the following:\n - `Longitude` is a number in the range (inclusive) `-180..180`\n - `Latitude` is a number in the range (inclusive) `-90..90`\n - `Altitude` is a number in the range (inclusive) `-6371008.7714..20180000` (Earth center(-ish) up to the GPS satelite distance)\n - `Polygon` \"LinearRing\" are closed (first and last `Position` are identical)\n - ~~`Polygon` \"LinearRing\" have the correct winding (counterclockwise for exterior rings (outline), clockwise for interior rings (holes))~~ _(not yet enforced — planned for v2)_\n\n\n| type               | guard                  | strict guard                 | description                                                                                                        |\n| ------------------ | ---------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------ |\n| Position           | `isPosition`           | `isStrictPosition`           | validate whether the input is valid GeoJSON Position                                                               |\n| Point              | `isPoint`              | `isStrictPoint`              | validate whether the input is valid GeoJSON Point                                                                  |\n| MultiPoint         | `isMultiPoint`         | `isStrictMultiPoint`         | validate whether the input is valid GeoJSON MultiPoint                                                             |\n| LineString         | `isLineString`         | `isStrictLineString`         | validate whether the input is valid GeoJSON LineString                                                             |\n| MultiLineString    | `isMultiLineString`    | `isStrictMultiLineString`    | validate whether the input is valid GeoJSON MultiLineString                                                        |\n| Polygon            | `isPolygon`            | `isStrictPolygon`            | validate whether the input is valid GeoJSON Polygon                                                                |\n| MultiPolygon       | `isMultiPolygon`       | `isStrictMultiPolygon`       | validate whether the input is valid GeoJSON MultiPolygon                                                           |\n| GeometryCollection | `isGeometryCollection` | `isStrictGeometryCollection` | validate whether the input is valid GeoJSON GeometryCollection                                                     |\n| Geometry           | `isGeometry`           | `isStrictGeometry`           | validate whether the input is valid GeoJSON Geometry (`Point`, `LineString`, `Polygon` or their `Multi*` variants) |\n| Feature            | `isFeature`            | `isStrictFeature`            | validate whether the input is valid GeoJSON Feature                                                                |\n| FeatureCollection  | `isFeatureCollection`  | `isStrictFeatureCollection`  | validate whether the input is valid GeoJSON FeatureCollection                                                      |\n| GeoJSON            | `isGeoJSON`            | `isStrictGeoJSON`            | validate the input to be valid GeoJSON                                                                             |\n\n```ts\nimport { isPoint, isStrictPoint } from '@konfirm/geojson';\n\nconst point: Point = {\n    type: 'Point',\n    coordinates: [181, 91],\n};\n\nconsole.log('the point is a GeoJSON Point', isPoint(point)); // true, as the structure is up to specification\nconsole.log('the point is a strict GeoJSON Point', isStrictPoint(point)); // false, as the coordinates are not within the specified ranges\n```\n\n### intersect\n\nVerify whether the provided GeoJSON objects intersect.\n\nUsage: `intersect(\u003cGeometry(Collection)|Feature(Collection)\u003e, \u003cGeometry(Collection)|Feature(Collection)\u003e): boolean`\n\n```ts\nimport { intersect, Point, Feature } from '@konfirm/geojson';\n\nconst point: Point = {\n    type: 'Point',\n    coordinates: [1, 1],\n};\nconst feature: Feature = {\n    type: 'Feature',\n    properties: {\n        name: 'triangle'\n    },\n    geometry: {\n        type: 'Polygon',\n        coordinates: [[[0, 0], [0, 2], [2, 1], [0, 0]]],\n    },\n}\n\nconsole.log('point intersects feature', intersect(point, feature)); // true\nconsole.log('feature intersects point', intersect(feature, point)); // true\n```\n\n### distance\n\nObtain the (shortest) distance in meters between two GeoJSON objects. There are three formulas which can be used:\n\n - `cartesian` (default), calculates the distance between coordinates using the Pythagorean equation, this is the fastest formula at the cost of (huge amount of) accuracy\n - `haversine`, calculates the distance between coordinates using the [haversine formula](https://en.wikipedia.org/wiki/Haversine_formula), improves the accuracy to a level which is probably suitable for most needs with a decent performance\n - `vincenty`, calculates the distance between coordinates using the [Vincenty's formula](https://en.wikipedia.org/wiki/Vincenty%27s_formulae), the most accurate but the least performant algorithm.\n\nUsage: `distance(\u003cGeometry(Collection)|Feature(Collection)\u003e, \u003cGeometry(Collection)|Feature(Collection)\u003e [, \u003c'cartesian'|'haversine'|'vincenty'\u003e]): number`\n\n```ts\nimport { distance, Feature } from '@konfirm/geojson';\n\n    const a: Feature = {\n        type: 'Feature',\n        properties: {\n            name: 'Schiphol Airport, Amsterdam',\n        },\n        geometry: {\n            type: 'Point',\n            coordinates: [4.763889, 52.308333],\n        },\n    };\n    const b: Feature = {\n        type: 'Feature',\n        properties: {\n            name: 'John F. Kennedy International Airport, New York',\n        },\n        geometry: {\n            type: 'Point',\n            coordinates: [-73.778889, 40.639722],\n        },\n    };\n\n    console.log(distance(a, b));              // 8829424.604594177 ('cartesian' is the default)\n    console.log(distance(a, b, 'cartesian')); // 8829424.604594177\n    console.log(distance(a, b, 'haversine')); // 5847546.425707642\n    console.log(distance(a, b, 'vincenty'));  // 5863355.371234315\n```\n\n### SimpleGeometryIterator\n\nThe SimpleGeometryIterator class is a convenience helper utility which yields all simple Geometric shapes (`Point`, `LineString`, `Polygon`) from any GeoJSON object. Using a SimpleGeometryIterator allows you to focus on just implementing logic for the simple Geometric shapes whilst supporting any combination of GeoJSON objects as input.\n\n| input type           | yields type(s)                     | description                                                                              |\n| -------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------- |\n| `Point`              | `Point`                            | yields the `Point` geometry as is                                                        |\n| `MultiPoint`         | `Point`                            | yields every `Point` of the `MultiPoint`                                                 |\n| `LineString`         | `LineString`                       | yields the `LineString` geometry as is                                                   |\n| `MultiLineString`    | `LineString`                       | yields every `LineString` of the `MultiLineString`                                       |\n| `Polygon`            | `Polygon`                          | yields the `Polygon` geometry as is                                                      |\n| `MultiPolygon`       | `Polygon`                          | yields every `Polygon` of the `MultiPolygon`                                             |\n| `GeometryCollection` | `Point`, `LineString` or `Polygon` | yields every geometry contained within the collection (see the corresponing types above) |\n| `Feature`            | `Point`, `LineString` or `Polygon` | yields the geometry of a feature (see the corresponding types above)                     |\n| `FeatureCollection`  | `Point`, `LineString` or `Polygon` | yields every `Feature` (see `Feature`)                                                   |\n\n```ts\nimport type { Point, MultiPoint, LineString, MultiLineString, GeometryCollection, Feature, FeatureCollection } from '@konfirm/geojson';\nimport { SimpleGeometryIterator } from '@konfirm/geojson';\n\nconst point: Point = {\n    type: 'Point',\n    coordinates: [5.903949737548828, 51.991936460056515],\n};\nconst multipoint: MultiPoint = {\n    type: 'MultiPoint',\n    coordinates: [\n        [5.896482467651367, 52.00039200820837],\n        [5.888843536376953, 51.99912377779024],\n    ],\n};\nconst linestring: LineString = {\n    type: 'LineString',\n    coordinates: [\n        [5.9077370166778564, 51.9944435645134],\n        [5.90764045715332, 51.994209045542206],\n        [5.907415151596069, 51.99408683094357],\n    ],\n};\nconst multilinestring: MultiLineString = {\n    type: 'MultiLineString',\n    coordinates: [\n        [\n            [5.905205011367797, 51.99430813821511],\n            [5.905086994171143, 51.994261894995034],\n            [5.905033349990845, 51.99414958983319],\n            [5.9051138162612915, 51.994116558849626]\n        ],\n        [\n            [5.904818773269653, 51.993825885143515],\n            [5.905521512031555, 51.993551725259614],\n            [5.905789732933044, 51.99358805979856],\n        ],\n    ],\n};\nconst geometrycollection: GeometryCollection = {\n    type: 'GeometryCollection',\n    geometries: [point],\n};\nconst featurecollection: FeatureCollection = {\n    type: 'FeatureCollection',\n    features: [\n        {\n            type: 'Feature',\n            properties: {},\n            geometry: linestring,\n        },\n        {\n            type: 'Feature',\n            properties: {},\n            geometry: multilinestring,\n        },\n    ]\n};\n\nconst simplified = [...new SimpleGeometryIterator(multipoint, geometrycollection, featurecollection)];\n/*\n    [\n        {\n            type: 'Point',\n            coordinates: ...multipoint[0]\n        },\n        {\n            type: 'Point',\n            coordinates: ...multipoint[1]\n        },\n        {\n            type: 'Point',\n            coordinates: ...point\n        },\n        {\n            type: 'LineString',\n            coordinates: ...linestring\n        },\n        {\n            type: 'LineString',\n            coordinates: ...multilinestring[0]\n        },\n        {\n            type: 'LineString',\n            coordinates: ...multilinestring[1]\n        },\n    ]\n*/\n```\n\n## License\n\nMIT License Copyright (c) 2021-2023 Rogier Spieker (Konfirm)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonfirm%2Fgeojson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonfirm%2Fgeojson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonfirm%2Fgeojson/lists"}