New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reproject-bbox

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reproject-bbox - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

7

package.json
{
"name": "reproject-bbox",
"version": "0.5.0",
"version": "0.6.0",
"description": "Reproject a Bounding Box",

@@ -19,3 +19,3 @@ "main": "reproject-bbox.js",

"f": "npm run format",
"format": "npx prettier --print-width=180 --write pluggable.js reproject-bbox.js test.*js",
"format": "npx prettier --print-width=180 --write pluggable.js reproject-bbox.js test.js test.mjs test.ts",
"test:cjs": "node test.js",

@@ -51,3 +51,4 @@ "test:mjs": "node test.mjs",

"devDependencies": {
"flug": "^2.3.1"
"bbox-fns": "^0.3.0",
"flug": "^2.5.0"
},

@@ -54,0 +55,0 @@ "dependencies": {

@@ -1,15 +0,8 @@

function reprojectBoundingBoxPluggable({ bbox, reproject }) {
const [xmin, ymin, xmax, ymax] = bbox;
const bboxArray = require("bbox-fns/bbox-array.js");
const densePolygon = require("bbox-fns/dense-polygon.js");
const topleft = reproject([xmin, ymax]);
const topright = reproject([xmax, ymax]);
const bottomleft = reproject([xmin, ymin]);
const bottomright = reproject([xmax, ymin]);
const corners = [topleft, topright, bottomleft, bottomright];
const xs = corners.map((corner) => corner[0]);
const ys = corners.map((corner) => corner[1]);
return [Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)];
function reprojectBoundingBoxPluggable({ bbox, density, reproject }) {
const polygon = densePolygon(bbox, { density });
const ring = polygon[0];
return bboxArray(ring.map((pt) => reproject(pt)));
}

@@ -16,0 +9,0 @@

@@ -28,2 +28,29 @@ # reproject-bbox

# advanced usage
## density
You can increase the accuracy of your reprojected bounding box by increasing the point density.
Density is the number of points that you would like to add to each side of the bounding box.
If you pass in an array of two numbers, you can control how many points to add along the x and y-axis.
```js
import reprojectBoundingBox from "reproject-bbox";
const bbox = [ -2316545, -1971615, 1015455, 1512385 ];
reprojectBoundingBox({
bbox,
density: 100, // add 100 points to each side of the box before reprojecting
from: 6623,
to: 4326
});
reprojectBoundingBox({
bbox,
// add 11 points along the x-axis (11 to top side and 11 to bottom side)
// and 99 points along the y-axis (99 to left side and 99 to right side)
density: [11, 99],
from: 6623,
to: 4326
});
```
## proj4-fully-loaded dependency

@@ -30,0 +57,0 @@ This library depends on [proj4-fully-loaded](https://github.com/DanielJDufour/proj4-fully-loaded).

export default function reprojectBoundingBox({
bbox,
density,
from,

@@ -8,2 +9,3 @@ proj4: _proj4,

bbox: [number, number, number, number] | Readonly<[number, number, number, number]>,
density?: number | undefined,
from: number | string,

@@ -10,0 +12,0 @@ proj4?: any,

@@ -10,3 +10,3 @@ const merge = require("proj4-merge");

function reprojectBoundingBox({ bbox, from, proj4: _proj4, to }) {
function reprojectBoundingBox({ bbox, density, from, proj4: _proj4, to }) {
if (typeof from === "number") from = "EPSG:" + from;

@@ -23,3 +23,3 @@ if (typeof to === "number") to = "EPSG:" + to;

return reprojectBoundingBoxPluggable({ bbox, reproject: fwd });
return reprojectBoundingBoxPluggable({ bbox, density, reproject: fwd });
}

@@ -26,0 +26,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc