reproject-bbox
Advanced tools
Comparing version 0.12.0 to 0.13.0
{ | ||
"name": "reproject-bbox", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Reproject a Bounding Box", | ||
@@ -50,6 +50,6 @@ "main": "reproject-bbox.js", | ||
"devDependencies": { | ||
"flug": "^2.6.0" | ||
"flug": "^2.7.1" | ||
}, | ||
"dependencies": { | ||
"bbox-fns": "^0.11.0", | ||
"bbox-fns": "^0.19.0", | ||
"proj4-fully-loaded": "^0.2.0", | ||
@@ -56,0 +56,0 @@ "proj4-merge": "^0.1.1" |
@@ -70,2 +70,14 @@ # reproject-bbox | ||
## split | ||
reproject-bbox will automatically split bounding boxes where x=0 and y=0 before reprojecting and merging them back together. This can greatly improve accuracy for certain projections, especially ones around the poles. However, if you really want to turn it off, you can. | ||
```js | ||
reprojectBoundingBox({ | ||
bbox, | ||
from: 3857, | ||
split: false, // turn off automatic splitting | ||
to: 4326 | ||
}) | ||
``` | ||
## proj4-fully-loaded dependency | ||
@@ -72,0 +84,0 @@ This library depends on [proj4-fully-loaded](https://github.com/DanielJDufour/proj4-fully-loaded). |
@@ -12,4 +12,5 @@ export default function reprojectBoundingBox({ | ||
proj4?: any, | ||
split?: boolean | undefined, | ||
to: number | string | ||
}): [number, number, number, number]; | ||
const merge = require("proj4-merge"); | ||
const proj4 = require("proj4-fully-loaded"); | ||
const bboxMerge = require("bbox-fns/merge.js"); | ||
const bboxSplit = require("bbox-fns/split.js"); | ||
const reproject = require("bbox-fns/reproject.js"); | ||
@@ -12,3 +14,3 @@ | ||
function reprojectBoundingBox({ bbox, density, from, proj4: _proj4, to }) { | ||
function reprojectBoundingBox({ bbox, density, from, proj4: _proj4, split = true, to }) { | ||
if (from === 32767) throw new Error(CUSTOM_PROJECTION_ERROR.replace("{{%s}}", "from")); | ||
@@ -28,3 +30,11 @@ if (to === 32767) throw new Error(CUSTOM_PROJECTION_ERROR.replace("{{%s}}", "to")); | ||
return reproject(bbox, fwd, { density }); | ||
const bboxes = split ? bboxSplit(bbox, { x: [0], y: [0] }) : [bbox]; | ||
const bboxes_reprojected = bboxes.map((bbox) => { | ||
return reproject(bbox, fwd, { density }); | ||
}); | ||
const merged = bboxMerge(bboxes_reprojected); | ||
return merged; | ||
} | ||
@@ -31,0 +41,0 @@ |
Sorry, the diff of this file is too big to display
427310
7579
88
+ Addedbbox-fns@0.19.0(transitive)
+ Addedpreciso@0.12.2(transitive)
- Removedbbox-fns@0.11.0(transitive)
- Removedpreciso@0.11.1(transitive)
Updatedbbox-fns@^0.19.0