{"id":21096873,"url":"https://github.com/klarna/geofences-reducer","last_synced_at":"2025-09-16T12:37:43.706Z","repository":{"id":47369090,"uuid":"507003656","full_name":"klarna/geofences-reducer","owner":"klarna","description":"Reduces overlapping geofences","archived":false,"fork":false,"pushed_at":"2025-05-05T19:29:27.000Z","size":1241,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-01T13:19:45.463Z","etag":null,"topics":["circular","geofence","geohash","latitude","longitude","overlapping","radius","reducer","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@klarna/geofences-reducer","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klarna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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}},"created_at":"2022-06-24T12:33:06.000Z","updated_at":"2025-05-05T19:29:30.000Z","dependencies_parsed_at":"2025-05-16T16:34:46.275Z","dependency_job_id":"2fda258f-3ee3-4926-97af-3bba9c737145","html_url":"https://github.com/klarna/geofences-reducer","commit_stats":null,"previous_names":["klarna/geofences-reducer","klarna-incubator/geofences-reducer"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/klarna/geofences-reducer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarna%2Fgeofences-reducer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarna%2Fgeofences-reducer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarna%2Fgeofences-reducer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarna%2Fgeofences-reducer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klarna","download_url":"https://codeload.github.com/klarna/geofences-reducer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarna%2Fgeofences-reducer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275417239,"owners_count":25461031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"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":["circular","geofence","geohash","latitude","longitude","overlapping","radius","reducer","typescript"],"created_at":"2024-11-19T22:44:29.307Z","updated_at":"2025-09-16T12:37:43.671Z","avatar_url":"https://github.com/klarna.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Geofences Reducer\n\u003e Reduces overlapping geofences.\n\n[![Build Status][ci-image]][ci-url]\n[![License][license-image]][license-url]\n[![Developed at Klarna][klarna-image]][klarna-url]\n\n\nGiven a list of circular geofences, this library removes the overlapping items and returns a reduced list that could be used to represent the same area.\n\n## Usage example\n\n### Installation\n\nVia npm:\n\n```sh\nnpm install @klarna/geofences-reducer --save\n```\n\nVia yarn:\n\n```sh\nyarn add @klarna/geofences-reducer\n```\n\n### Usage\n\nWith JavaScript:\n\n```javascript\nconst reducer = require('@klarna/geofences-reducer')\n\nconst geofences = [\n  {\n    latitude: 51.51,\n    longitude: -0.36,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.51,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.6,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.51,\n    longitude: 0.12,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.15,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.72,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  }\n]\n\nconst geofencesReduced = reducer.reduce(geofences)\n```\n\nWith TypeScript:\n\n```typescript\nimport * as reducer from '@klarna/geofences-reducer'\n\ntype Geofence = {\n  latitude: number\n  longitude: number\n  radius: number\n}\n\nconst geofences: Geofence[] = [\n  {\n    latitude: 51.51,\n    longitude: -0.36,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.51,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.6,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.51,\n    longitude: 0.12,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.15,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  },\n  {\n    latitude: 51.72,\n    longitude: -0.07,\n    radius: 20000 // in meters\n  }\n]\n\nconst geofencesReduced: Geofence[] = reducer.reduce(geofences)\n```\n\nResult:\n\n![Geohashes](./docs/images/geofences_reduced.png)\n\n### Optional Configuration\n\n#### Precision\n\nPrecision can be customized as follows:\n\n```javascript\nconst config = {\n  precision: 5 // 6 by default, accepts 1 to 12\n}\n\nconst geofencesReduced = reducer.reduce(geofences, config)\n```\n\n## Development setup\n\nInstall project dependencies:\n\n```sh\nnpm install\n```\n\nRun automated test-suite:\n\n```sh\nnpm test\n```\n\n## How to contribute\n\nSee our guide on [contributing](.github/CONTRIBUTING.md).\n\n## Release History\n\nSee our [changelog](CHANGELOG.md).\n\n## License\n\nCopyright © 2021 Klarna Bank AB\n\nFor license details, see the [LICENSE](LICENSE) file in the root of this project.\n\n\n\u003c!-- Markdown link \u0026 img dfn's --\u003e\n[ci-image]: https://img.shields.io/badge/build-passing-brightgreen?style=flat-square\n[ci-url]: https://github.com/klarna/geofences-reducer/actions\n[license-image]: https://img.shields.io/badge/license-Apache%202-blue?style=flat-square\n[license-url]: http://www.apache.org/licenses/LICENSE-2.0\n[klarna-image]: https://img.shields.io/badge/%20-Developed%20at%20Klarna-black?labelColor=ffb3c7\u0026style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAALQAAAAAQAAAtAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAABCgAwAEAAAAAQAAAA4AAAAA0LMKiwAAAAlwSFlzAABuugAAbroB1t6xFwAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAAVBJREFUKBVtkz0vREEUhsdXgo5qJXohkUgQ0fgFNFpR2V5ClP6CQu9PiB6lEL1I7B9A4/treZ47c252s97k2ffMmZkz5869m1JKL/AFbzAHaiRbmsIf4BdaMAZqMFsOXNxXkroKbxCPV5l8yHOJLVipn9/vEreLa7FguSN3S2ynA/ATeQuI8tTY6OOY34DQaQnq9mPCDtxoBwuRxPfAvPMWnARlB12KAi6eLTPruOOP4gcl33O6+Sjgc83DJkRH+h2MgorLzaPy68W48BG2S+xYnmAa1L+nOxEduMH3fgjGFvZeVkANZau68B6CrgJxWosFFpF7iG+h5wKZqwt42qIJtARu/ix+gqsosEq8D35o6R3c7OL4lAnTDljEe9B3Qa2BYzmHemDCt6Diwo6JY7E+A82OnN9HuoBruAQvUQ1nSxP4GVzBDRyBfygf6RW2/gD3NmEv+K/DZgAAAABJRU5ErkJggg==\n[klarna-url]: https://klarna.github.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklarna%2Fgeofences-reducer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklarna%2Fgeofences-reducer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklarna%2Fgeofences-reducer/lists"}