# within-canada

> Check if a Lat/Lng Coordinate is within a specific Canadian Province or Territory

Latest version **1.0.0** (published 2020-12-03) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install within-canada
pnpm add within-canada
yarn add within-canada
bun add within-canada
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-03 |
| First published | 2020-12-03 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 24.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Humphrey |
| Maintainers | humphd |

## Links

- npm: https://www.npmjs.com/package/within-canada
- Repository: https://github.com/humphd/within-canada
- Homepage: https://github.com/humphd/within-canada#readme
- Issues: https://github.com/humphd/within-canada/issues
- npm.io page: https://npm.io/package/within-canada

## Dependencies (3)

- [@turf/helpers](https://npm.io/package/@turf/helpers.md) ^6.1.4
- [@turf/invariant](https://npm.io/package/@turf/invariant.md) ^6.1.2
- [@turf/boolean-point-in-polygon](https://npm.io/package/@turf/boolean-point-in-polygon.md) ^6.0.1

## Recent versions

- 1.0.0 (latest) — 2020-12-03

## README

# within-canada

Check if a Lat/Lng Coordinate is within the specified Canadian Province or Territory.

## Examples

```js
import canada from 'within-canada';

const toronto = { lat: 43.6532, lng: -79.3832 };
// Check for Toronto within Ontario (ON)
canada.on(toronto.lat, toronto.lng);
// true
```

However, it is much more space efficient to only request the function for the
province/territory you actually need:

```js
// get only the on() function (on its own)
import ontario from 'within-canada/on'

const toronto = { lat: 43.6532, lng: -79.3832 };
on(toronto.lat, toronto.lng);
// true
```

Each province/territory is available using the two character region code
listed below.

## API

The following functions are available, where `lat` and `lng` are of type `Number`:

- `on(lat, lng)` returns `true` if the point is within Ontario
- `ab(lat, lng)` returns `true` if the point is within Alberta
- `bc(lat, lng)` returns `true` if the point is within British Columbia
- `nl(lat, lng)` returns `true` if the point is within Newfoundland and Labrador
- `pe(lat, lng)` returns `true` if the point is within Prince Edward Island
- `ns(lat, lng)` returns `true` if the point is within Nova Scotia
- `nb(lat, lng)` returns `true` if the point is within New Brunswick
- `qc(lat, lng)` returns `true` if the point is within Québec
- `mb(lat, lng)` returns `true` if the point is within Manitoba
- `sk(lat, lng)` returns `true` if the point is within Saskatchewan
- `yt(lat, lng)` returns `true` if the point is within Yukon Territory
- `nt(lat, lng)` returns `true` if the point is within Northwest Territories
- `nu(lat, lng)` returns `true` if the point is within Nunavut

---
_Source: https://npm.io/package/within-canada · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
