# robust-point-in-polygon

> Exactly test if a point is inside, outside or on the boundary of a polygon

Latest version **1.0.3** (published 2015-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install robust-point-in-polygon
pnpm add robust-point-in-polygon
yarn add robust-point-in-polygon
bun add robust-point-in-polygon
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-01-29 |
| First published | 2014-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/robust-point-in-polygon) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 250 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | robust, point, in, polygon, pnp, inside, outside, on, exact, arithmetic |

## Links

- npm: https://www.npmjs.com/package/robust-point-in-polygon
- Repository: https://github.com/mikolalysenko/robust-point-in-polygon
- Issues: https://github.com/mikolalysenko/robust-point-in-polygon/issues
- npm.io page: https://npm.io/package/robust-point-in-polygon

## Dependencies (1)

- [robust-orientation](https://npm.io/package/robust-orientation.md) ^1.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.3 (latest) — 2015-01-29
- 1.0.2 — 2015-01-29
- 1.0.1 — 2015-01-29
- 1.0.0 — 2014-05-06
- 0.0.0 — 2014-03-28

## README

robust-point-in-polygon
=======================
Exactly determines if a point is contained in a 2D polygon.

# Example

```javascript
var classifyPoint = require("robust-point-in-polygon")
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ]

console.log(
  classifyPoint(polygon, [1.5, 1.5]),
  classifyPoint(polygon, [1, 2]),
  classifyPoint(polygom, [100000, 10000]))
```

Output:

```
-1 0 1
```

# Install

```
npm install robust-point-in-polygon
```

# API

### `require("robust-point-in-polygon")(loop, point)`
Tests if a point is contained in the interior of a simple polygon

* `loop` is an array of vertices for the polygon
* `point` is a 2D point which is classified against the polygon

**Returns** An integer which determines the position of `point` relative to `polygon`.  This has the following interpretation:

* `-1` if `point` is contained inside `loop`
* `0` if `point` is on the boundary of `loop`
* `1` if `point` is outside `loop`

# Credits
(c) 2014 Mikola Lysenko. MIT License

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