Skip to content

Commit

Permalink
added perimeter
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Aug 22, 2021
1 parent 1be8eb3 commit 572278c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Once you've created a GeoExtent, you will have access to the following propertie
| height | 121 | The height of the extent in units of the [srs](https://en.wikipedia.org/wiki/Spatial_reference_system). This is often either degrees latitude or meters. |
| width | 93 | The width of the extent in units of the [srs](https://en.wikipedia.org/wiki/Spatial_reference_system). This is often either degrees longitude or meters. |
| area | 11253 | The area of the extent in units of the [srs](https://en.wikipedia.org/wiki/Spatial_reference_system). This is often in degrees or meters squared. Because this uses the units of the srs, this is just an approximation and can't be relied upon as the "true" area. |
| perimeter | 428 | The perimeter of the extent in units of the [srs](https://en.wikipedia.org/wiki/Spatial_reference_system). This is often in degrees or meters. Because this uses the units of the srs, this is just an approximation and can't be relied upon as the "true" perimeter.
| center | { x: -25.5, y: 13.5 } | The center of the extent or half-way point along the x and y directions. |
| bottomLeft | { x: -72, y: -47 } | The bottom-left corner of the extent |
| bottomRight | { x: 21, y: -47 } | The bottom-right corner of the extent |
Expand Down
1 change: 1 addition & 0 deletions geo-extent.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class GeoExtent {
];

this.area = this.width * this.height;
this.perimeter = 2 * this.width + 2 * this.height;
this.bbox = [xmin, ymin, xmax, ymax];
this.center = { x: avg(xmin, xmax), y: avg(ymin, ymax) };
this.str = this.bbox.join(",");
Expand Down
2 changes: 2 additions & 0 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const NORTH_WEST_QUARTER_SPHERE = [-180, 0, 0, 90];
const AS_OBJ_RESULT = {
srs: 'EPSG:4326',
area: AREA,
perimeter: 2 * WIDTH + 2 * HEIGHT,
bbox: BBOX,
center: CENTER,
xmin: XMIN,
Expand Down Expand Up @@ -65,6 +66,7 @@ test("create from points", ({ eq }) => {
topLeft: { x: 147, y: -18 },
topRight: { x: 147, y: -18 },
area: 0,
perimeter: 0,
bbox: [ 147, -18, 147, -18 ],
center: { x: 147, y: -18 },
str: '147,-18,147,-18',
Expand Down

0 comments on commit 572278c

Please sign in to comment.