reproject-bbox
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "reproject-bbox", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Reproject a Bounding Box", | ||
@@ -50,3 +50,3 @@ "main": "reproject-bbox.js", | ||
"devDependencies": { | ||
"flug": "^2.5.0" | ||
"flug": "^2.6.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "dependencies": { |
@@ -28,2 +28,17 @@ # reproject-bbox | ||
# advanced usage | ||
## well-known text | ||
Because reproject-bbox passes the `from` and `to` parameters to [proj4js](http://proj4js.org/) and proj4js supports | ||
[Well-Known Text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems), | ||
you can also pass WKT strings and Proj4JS strings in place of EPSG Codes. | ||
```js | ||
import reprojectBoundingBox from "reproject-bbox"; | ||
// example WKT and PROJ4 Strings from http://proj4js.org/ | ||
reprojectBoundingBox({ | ||
bbox, | ||
from: 'PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",42.68333333333333],PARAMETER["standard_parallel_2",41.71666666666667],PARAMETER["latitude_of_origin",41],PARAMETER["central_meridian",-71.5],PARAMETER["false_easting",200000],PARAMETER["false_northing",750000],AUTHORITY["EPSG","26986"],AXIS["X",EAST],AXIS["Y",NORTH]]', | ||
to: "+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" | ||
}); | ||
``` | ||
## density | ||
@@ -30,0 +45,0 @@ You can increase the accuracy of your reprojected bounding box by increasing the point density. |
@@ -9,3 +9,9 @@ const merge = require("proj4-merge"); | ||
const CUSTOM_PROJECTION_ERROR = | ||
"[reproject-bbox] You passed in a value of 32767 for {{%s}}, which means a custom non-standard projection. Please pass in a Well-Known Text or PROJ4JS String instead."; | ||
function reprojectBoundingBox({ bbox, density, from, proj4: _proj4, to }) { | ||
if (from === 32767) throw new Error(CUSTOM_PROJECTION_ERROR.replace("{{%s}}", "from")); | ||
if (to === 32767) throw new Error(CUSTOM_PROJECTION_ERROR.replace("{{%s}}", "to")); | ||
if (typeof from === "number") from = "EPSG:" + from; | ||
@@ -12,0 +18,0 @@ if (typeof to === "number") to = "EPSG:" + to; |
Sorry, the diff of this file is too big to display
423383
7487
76