1.7.27 • Published 3 years ago

@dra2020/poly v1.7.27

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

poly

Small utility library of convenient polygon functions used for geojson project.

These library functions all take either a GeoJSON polygon or multipolygon feature or take a bare set of points (in the same basic format as either the GeoJSON polygon). Look to the reference but basically, a polygon is an array whose first member is the outer ring and subsequent members are the internal holes.

A multipolygon is just an array of polygons.

A ring is an array of points. The array should be at least 4 points long and the first and last points should be equal.

A point is an array of lon, lat (that is, x, y).

Earth Radius

export declare const EARTH_RADIUS = 6371000;

polyNormalize

export declare function polyNormalize(poly: any): any;

Used internally to normalize the input for subsequent processing. Exposed if you want to be consistent. The result is either null or the points array in multi-polygon format.

polyArea

export declare function polyArea(poly: any): number;

Compute the area of the polygon in meters squared.

polyPerimeter

export declare function polyPerimeter(poly: any): number;

Compute the perimeter of a polygon in meters.

Circle class

export declare class Circle { x: number; y: number; r: number; constructor(x: number, y: number, r: number); }

Used for subsequent functions.

polyToCircle

export declare function polyToCircle(poly: any): Circle | null;

Return smallest circle that encloses all points.

polyToPolsbyPopperCircle

export declare function polyToPolsbyPopperCircle(poly: any): Circle | null;

Returns circle whose perimeter is equal to the perimeter of the bounding perimeter of the polygon.

polyFromCircle

export declare function polyFromCircle(c: Circle, nSegments?: number): any;

Return a polygon (in normalized form) that approximates the circle provided. NSegments specifies the number of segments to use (must be at least 8).

polyConvexHull

export declare function polyConvexHull(poly: any): any;

A.M. Andrew's monotone chain 2D convex hull algorithm.

Compactness Description

export interface CompactnessDescription { value: number; reock: number; polsby_popper: number; convex_hull: number; schwartzberg: number; }

Type returned from polyCompactness function.

polyCompactness

export declare function polyCompactness(poly: any): CompactnessDescription;

Compute the compactness of the polygon.

PolyDescription

export interface PolyDescription { npoly: number; nhole: number; npoint: number; }

Type returned from polyDescribe.

polyDescribe

export declare function polyDescribe(poly: any): PolyDescription;

Describe the given polygon.

1.7.27

3 years ago

1.7.25

3 years ago

1.7.26

3 years ago

1.7.24

3 years ago

1.7.23

3 years ago

1.7.22

3 years ago

1.7.21

3 years ago

1.7.20

3 years ago

1.7.19

3 years ago

1.7.18

4 years ago

1.7.16

4 years ago

1.7.15

4 years ago

1.7.14

4 years ago

1.7.13

4 years ago

1.7.12

4 years ago

1.7.11

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.7

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.48

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.44

4 years ago

1.0.45

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago