Skip to content

Commit

Permalink
docs: update readme with explainations (#5)
Browse files Browse the repository at this point in the history
* docs: update readme with explainations

Describe how the package works and notes for developers.

* docs: fix example destructure

* docs: additional info
  • Loading branch information
Tyler Stewart authored Aug 11, 2020
1 parent c62ac76 commit 5d23274
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
```ts
import {find} from 'canadian-city-timezones';

const result = await find((city, province) => city === 'Lethbridge' && province === 'Alberta');
const result = await find(({city, province}) => city === 'Lethbridge' && province === 'Alberta');
result.city // Lethbridge
result.province // Alberta
result.timezone // America/Edmonton
Expand Down Expand Up @@ -52,6 +52,19 @@ Yields all values.
}
```

## How Does This Work?

Before this package is published, census data listing all dwellings in Canada is downloaded from `statcan.gc.ca`. This is filtered by applicable types (city, town, etc) and sent to `mapbox.com` to find the dwelling's geographic coordinates (latitude & longitude). From there, the coordinates are given to [`geo-tz`](https://github.com/evansiroky/node-geo-tz) which returns the timezone.

This data is then written to a CSV file and published along side the simple interface for interacting with the data. So look ups are quick since it is just checking a local CSV.

The interface works with an async generator, reading this CSV file line by line to avoid loading all data into memory.

## Development

Timezones are generated automatically by pulling the list of areas from `gc.ca` and feeding them into `mapbox.com` to get their coordinates, then getting the timezone using [`geo-tz`](https://github.com/evansiroky/node-geo-tz).
We want to reduce the number of dependencies the end user encounters, keep that in mind when working within this repository.

Data can be generated by manually triggering [the `Generate` workflow](https://github.com/autovance/canadian-city-timezones/actions?query=workflow%3AGenerate).

Releases are done automatically when commits are merged into master using [semantic-release](https://github.com/semantic-release/semantic-release). Please use appropriate commit prefixes.
Changes that only affect the generation of data should be prefixed with `generate:` to avoid triggering a release.

0 comments on commit 5d23274

Please sign in to comment.