{"id":19050479,"url":"https://github.com/blakek/standardize-geolocation","last_synced_at":"2025-04-24T01:23:12.675Z","repository":{"id":38272807,"uuid":"75962981","full_name":"blakek/standardize-geolocation","owner":"blakek","description":"🛸 takes geolocations of different formats and outputs a standardized version","archived":false,"fork":false,"pushed_at":"2023-03-04T03:25:15.000Z","size":1823,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T10:16:17.579Z","etag":null,"topics":["geolocation","javascript","latitude","longitude","takes-geolocations"],"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/blakek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-08T18:11:17.000Z","updated_at":"2021-11-11T19:00:57.000Z","dependencies_parsed_at":"2023-02-05T02:01:03.065Z","dependency_job_id":null,"html_url":"https://github.com/blakek/standardize-geolocation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fstandardize-geolocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fstandardize-geolocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fstandardize-geolocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fstandardize-geolocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakek","download_url":"https://codeload.github.com/blakek/standardize-geolocation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250541825,"owners_count":21447585,"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","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":["geolocation","javascript","latitude","longitude","takes-geolocations"],"created_at":"2024-11-08T23:15:03.439Z","updated_at":"2025-04-24T01:23:12.652Z","avatar_url":"https://github.com/blakek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# standardize-geolocation\n\n\u003e takes geolocations of different formats and outputs a standardized version\n\nThere are several ways of representing geolocations:\n\n- latitude and longitude\n- latitude, longitude, and elevation\n- `longitude` vs. `lon` vs. `long` vs. `lng`\n- [GeoJSON](https://tools.ietf.org/html/rfc7946)\n- ...and more\n\nThis module just takes in a geolocation and tries to parse it to a standardized\nformat everyone can use and rely on: an object with keys of `latitude`, `longitude`,\nand `elevation`.\n\n## Install\n\nUsing [Yarn]:\n\n```bash\n$ yarn add standardize-geolocation\n```\n\n…or using [npm]:\n\n```bash\n$ npm i --save standardize-geolocation\n```\n\n## Usage\n\n```js\nimport { standardizeGeolocation } from 'standardize-geolocation';\n\nconst location = standardizeGeolocation({\n  lat: 12.3456,\n  lng: -65.4321\n});\n//» { latitude: 12.3456, longitude: -65.4321, elevation: undefined }\n\nconst points = [\n  { lat: 85.238749, lng: 12.923587, elevation: 982 },\n  { lat: 85.238749, lng: 12.923587, elevation: 982 },\n  { lat: 85.238749, lng: 12.923587, elevation: 982 },\n  [85.238749, 12.923587, 982],\n  { lat: 85.238749, lng: 12.923587 }\n];\n\nconst locations = points.map(standardizeGeolocation);\n// [\n//   { elevation: 982, latitude: 85.238749, longitude: 12.923587 },\n//   { elevation: 982, latitude: 85.238749, longitude: 12.923587 },\n//   { elevation: 982, latitude: 85.238749, longitude: 12.923587 },\n//   { elevation: 982, latitude: 85.238749, longitude: 12.923587 },\n//   { elevation: undefined, latitude: 85.238749, longitude: 12.923587 }\n// ]\n```\n\n## API\n\n### `standardizeGeolocation`\n\n```ts\nfunction standardizeGeolocation(\n  point: GeolocationInput\n): StandardizedGeolocation;\n```\n\nAttempts to create an object in this format from any known format:\n\n```ts\n{\n  elevation: number | undefined;\n  latitude: number;\n  longitude: number;\n}\n```\n\nHere's a (non-exhaustive) list of formats this will standardize:\n\n**Arrays:**\n\n- `[latitude, longitude]`\n- `[latitude, longitude, elevation]`\n\nIf an array is detected to be in a GeoJSON object, latitude and longitude will be reversed:\n\n`{ coordinates: [longitude, latitude]; }`\n\n**Objects:**\n\nLatitude keys:\n\n- `lat`\n- `latitude`\n\nLongitude keys:\n\n- `lng`\n- `lon`\n- `long`\n- `longitude`\n\nElevation keys:\n\n- `alt`\n- `altitude`\n- `elev`\n- `elevation`\n\n**Nested objects:**\n\nIf the passed object has one of these properties at the top level, it will attempt to convert it to a geolocation:\n\n- `geometry`\n- `location`\n- `position`\n\n## Contributing\n\n[Node.js] and [Yarn] are required to work with this project.\n\nTo install all dependencies, run:\n\n```bash\nyarn\n```\n\n### Useful Commands\n\n|                     |                                                 |\n| ------------------- | ----------------------------------------------- |\n| `yarn build`        | Builds the project to `./dist`                  |\n| `yarn format`       | Format the source following the Prettier styles |\n| `yarn test`         | Run project tests                               |\n| `yarn test --watch` | Run project tests, watching for file changes    |\n\n## See Also\n\n- [`blakek/geo2zip`](https://github.com/blakek/geo2zip) - translates latitude / longitude geolocations to the nearest corresponding U.S. zip code\n- [`blakek/us-zips`](https://github.com/blakek/us-zips) - a list of US ZIP codes and their geolocations\n\n## License\n\nMIT\n\n[node.js]: https://nodejs.org/\n[yarn]: https://yarnpkg.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Fstandardize-geolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakek%2Fstandardize-geolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Fstandardize-geolocation/lists"}