{"id":23186408,"url":"https://github.com/mateuszkocz/angular-coordinates","last_synced_at":"2025-06-26T15:34:14.684Z","repository":{"id":57178205,"uuid":"83208133","full_name":"mateuszkocz/angular-coordinates","owner":"mateuszkocz","description":"Angular library to parse and display geographical coordinates.","archived":false,"fork":false,"pushed_at":"2021-03-05T20:31:01.000Z","size":62,"stargazers_count":6,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-25T07:09:30.679Z","etag":null,"topics":["angular","angular2","coordinates","geolocation","library"],"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/mateuszkocz.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":"2017-02-26T12:52:34.000Z","updated_at":"2022-01-18T11:21:01.000Z","dependencies_parsed_at":"2022-08-30T05:32:14.621Z","dependency_job_id":null,"html_url":"https://github.com/mateuszkocz/angular-coordinates","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mateuszkocz/angular-coordinates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateuszkocz%2Fangular-coordinates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateuszkocz%2Fangular-coordinates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateuszkocz%2Fangular-coordinates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateuszkocz%2Fangular-coordinates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mateuszkocz","download_url":"https://codeload.github.com/mateuszkocz/angular-coordinates/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateuszkocz%2Fangular-coordinates/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261907001,"owners_count":23228363,"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":["angular","angular2","coordinates","geolocation","library"],"created_at":"2024-12-18T10:16:02.551Z","updated_at":"2025-06-26T15:34:14.656Z","avatar_url":"https://github.com/mateuszkocz.png","language":"TypeScript","readme":"# Angular library to parse and display geographical coordinates.\n[![Build Status](https://travis-ci.org/mateuszkocz/angular-coordinates.svg?branch=master)](https://travis-ci.org/mateuszkocz/angular-coordinates)\n[![Code Climate](https://codeclimate.com/github/mateuszkocz/angular-coordinates/badges/gpa.svg)](https://codeclimate.com/github/mateuszkocz/angular-coordinates)\n[![Test Coverage](https://codeclimate.com/github/mateuszkocz/angular-coordinates/badges/coverage.svg)](https://codeclimate.com/github/mateuszkocz/angular-coordinates/coverage)\n\n## Installation\n\n```\nnpm install angular-coordinates --save\n```\n\n## Usage\n### Module\nTo have access to the Coordinates service, component and pipe, you need to import the Coordinates module into your\nAppModule or any other module you want to use the library.\n\n```ts\n// app.module.ts\n\nimport {NgModule} from '@angular/core'\nimport {CoordinatesModule} from 'angular-coordinates';\n\n@NgModule({\n  imports: [\n    CoordinatesModule\n  ]\n})\nclass AppModule {}\n```\n\n### Component\n#### Information\nOne way to display formatted coordinates is to use the GeoCoordinates component exposed by the CoordinatesModule.\nThe component expects at least the value to be converted. Optionally you can provide a transformation type or direction.\n\nTransformation type comes from the TransformationType enum and refers to one of the two types: \"to degrees\" (more human\nreadable, eg. \"10°0'0\" N\") and \"to digit\". By default, the \"to degrees\" value is used.\n\nDirection is an enum with two values: latitude and longitude. The direction information is used when displaying\ngeographical direction (N, S, W, E) and with the value validation. By default no direction is used so the output - if\nusing the \"to degree\" transformation - won't get the direction marker and the value will allow [-180, 180] range.\n\n#### Example\n```ts\nimport {Component} from '@angular/core'\nimport {TransformationType, Direction} from 'angular-coordinates';\n\n@Component({\n  template: `\n    \u003cgeo-coordinates [value]=\"10\"\u003e\u003c/geo-coordinates\u003e\n    \u003cgeo-coordinates [value]=\"10.5\" [direction]=\"direction.Latitude\"\u003e\u003c/geo-coordinates\u003e\n    \u003cgeo-coordinates [value]=\"stringValue\" [type]=\"type.toDigit\"\u003e\u003c/geo-coordinates\u003e`\n})\nclass MyComponent {\n  stringValue = '10°0\\'0\" N'\n  direction = Direction\n  type = TransformationType\n}\n```\n\n```html\n\u003c!-- Outcome --\u003e\n10°0'0\"     \u003c!-- Direction was not provided, so no \"N\" or \"E\". Transformed to degree by default. --\u003e\n10°30'0\" N  \u003c!-- Known direction. --\u003e\n10          \u003c!-- Transforming to digit. --\u003e\n```\n\n### Pipe\n#### Information\nThe `coordinates` pipe works in the same way as the GeoComponent. Actually, the component just uses `coordinates` internally,\nso there's no difference in how they work.\n\nPipe accepts two parameters: transformation type and direction. Refer to the component description to learn what they do.\nBoth are optional.\n\n#### Example\n```ts\nimport {Component} from '@angular/core'\nimport {TransformationType, Direction} from 'angular-coordinates';\n\n@Component({\n  template: '{{ value | coordinates:TransformationType.toDegree:Direction.Latitude }}'\n})\nclass MyComponent {\n  value = 10\n}\n```\n\n```html\n`10°0'0\" N`\n```\n\n### Service\n#### Information\nThe coordinates service handles all the logic behind coordinates conversion and is used by both the pipe and component.\n\n#### Methods\n\n##### `transform`\nThis is the most generic method of transformation. It expects the value to be transformed, transformation type (from the\nTransformationType enum) and - optionally - the direction (from the Direction enum).\n\nThe `transform` methods returns either a string or a number, depending on what transformation type was used. If the value\nwas invalid, empty string is returned instead.\n\n```ts\ntransform(value: string | number | null, transformationType: TransformationType, direction?: Direction): string | number\n```\n\n##### `transformToDigit`\nSpecific transformation that transforms the provided value into a number.\n\n```ts\ntransformToDigit(value: string | number): number\n```\n\n##### `transformToDegrees`\nSpecific transformation that transforms the provided value into a formatted string. Optionally accepts the direction\n(from the Direction enum) for enhanced validation and geographical direction marker (\"N\", \"S\", \"W\", \"E\").\n\n```ts\ntransformToDegrees(value: string | number, direction?: Direction): string\n```\n\n##### `isValueValid`\nGeneric validator informing if the provided value is a proper digit or a string. Validity depends on the range, direction\nand format. Optional direction allows to properly validate the range (latitude is only [-90, 90] while longitude is\n[-180, 180]) and the geographical marker (eg. \"N\" and \"S\" are not valid longitude markers).\n\n```ts\nisValueValid(value: string | number | null, direction?: Direction): boolean\n```\n\n##### `isValidDegree`\nTests if the provided value is a valid coordinates string. Works in the same way as the `isValueValid`, but only for\nstrings.\n\n```ts\nisValidDegree(value: string | number | null, direction?: Direction): boolean\n```\n\n##### `isValidDigit`\nTests if the provided value is a proper coordinates digit. Takes the ranges in consideration and - if the direction is provided -\nenhances this validation by understanding the proper boundaries for each direction.\n\n```ts\nisValidDigit(value: string | number | null, direction?: Direction): boolean\n```\n\n#### Example\n```ts\nimport {Component} from '@angular/core'\nimport {CoordinatesService, TransformationType, Direction} from 'angular-coordinates';\n\n@Component({\n  template: '{{geolocation}}' // `10°0'0\" N`\n})\nclass MyComponent {\n  constructor(coordinatesService: CoordinatesService) {\n    this.geolocation = coordinatesService.transform(10, TransformationType.ToDegree, Direction.Latitude) // =\u003e `10°0'0\" N`\n    this.valid = coordinatesService.isValueValid(100, Direction.Latitude) // false, latitude allows only [-90, 90] values.\n  }\n}\n```\n\n## License\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateuszkocz%2Fangular-coordinates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmateuszkocz%2Fangular-coordinates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateuszkocz%2Fangular-coordinates/lists"}