Skip to main content

pointInPolygon

Whether a point lies inside a polygon or multipolygon. Holes are respected: a point in a hole is outside, and a point inside an island within a hole is inside. A point on an edge counts as inside unless ignoreBoundary is set. An empty polygon holds nothing.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { pointInPolygon } from "@mapcairn/core";

function pointInPolygon(point: PointInput, polygon: GeometryInput, options?: PointInPolygonOptions): boolean;

Description​

The test is planar, on the longitude and latitude as given, so it is sound for any polygon that does not cross the antimeridian (GeoJSON splits those at 180 degrees, and each piece works).

Parameters​

  • point (PointInput)
  • polygon (GeometryInput)
  • options? (PointInPolygonOptions)

Returns​

boolean

Throws​

  • GeometryError of kind invalid for a malformed point or polygon, unsupported when the shape is not a Polygon or MultiPolygon.

See also​

Source: packages/core/src/geometry/queries.ts:98