First commit
This commit is contained in:
commit
87d22a4516
12
cdconfig.json
Normal file
12
cdconfig.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "tethys-data-provider",
|
||||||
|
"arcgisVersion": "11.1.0",
|
||||||
|
"parentServiceType": "FeatureServer",
|
||||||
|
"customdataRuntimeVersion": "1",
|
||||||
|
"type": "provider",
|
||||||
|
"properties": {
|
||||||
|
"hosts": false,
|
||||||
|
"disableIdParam": true
|
||||||
|
},
|
||||||
|
"fileName": "tethys-data-provider.cdpk"
|
||||||
|
}
|
6
config/default.json
Normal file
6
config/default.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"tethys": {
|
||||||
|
"url": "https://www.tethys.at/oai?verb=ListRecords&metadataPrefix=oai_datacite",
|
||||||
|
"resumptionUrl": "https://www.tethys.at/oai?verb=ListRecords&resumptionToken="
|
||||||
|
}
|
||||||
|
}
|
12
node_modules/.bin/json5
generated
vendored
Normal file
12
node_modules/.bin/json5
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../json5/lib/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../json5/lib/cli.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/json5.cmd
generated
vendored
Normal file
17
node_modules/.bin/json5.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\json5\lib\cli.js" %*
|
28
node_modules/.bin/json5.ps1
generated
vendored
Normal file
28
node_modules/.bin/json5.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
12
node_modules/.bin/xml-js
generated
vendored
Normal file
12
node_modules/.bin/xml-js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../xml-js/bin/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../xml-js/bin/cli.js" "$@"
|
||||||
|
fi
|
17
node_modules/.bin/xml-js.cmd
generated
vendored
Normal file
17
node_modules/.bin/xml-js.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\xml-js\bin\cli.js" %*
|
28
node_modules/.bin/xml-js.ps1
generated
vendored
Normal file
28
node_modules/.bin/xml-js.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../xml-js/bin/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../xml-js/bin/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../xml-js/bin/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../xml-js/bin/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
101
node_modules/.package-lock.json
generated
vendored
Normal file
101
node_modules/.package-lock.json
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
{
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/config": {
|
||||||
|
"version": "3.3.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/config/-/config-3.3.9.tgz",
|
||||||
|
"integrity": "sha512-G17nfe+cY7kR0wVpc49NCYvNtelm/pPy8czHoFkAgtV1lkmcp7DHtWCdDu+C9Z7gb2WVqa9Tm3uF9aKaPbCfhg==",
|
||||||
|
"dependencies": {
|
||||||
|
"json5": "^2.2.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/json5": {
|
||||||
|
"version": "2.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||||
|
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||||
|
"bin": {
|
||||||
|
"json5": "lib/cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mgrs": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
|
||||||
|
},
|
||||||
|
"node_modules/node-fetch": {
|
||||||
|
"version": "2.6.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||||
|
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/proj4": {
|
||||||
|
"version": "2.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proj4/-/proj4-2.9.0.tgz",
|
||||||
|
"integrity": "sha512-BoDXEzCVnRJVZoOKA0QHTFtYoE8lUxtX1jST38DJ8U+v1ixY70Kpwi0Llu6YqSWEH2xqu4XMEBNGcgeRIEywoA==",
|
||||||
|
"dependencies": {
|
||||||
|
"mgrs": "1.0.0",
|
||||||
|
"wkt-parser": "^1.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/sax": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
|
},
|
||||||
|
"node_modules/tr46": {
|
||||||
|
"version": "0.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
|
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||||
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tr46": "~0.0.3",
|
||||||
|
"webidl-conversions": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wkt-parser": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.3.tgz",
|
||||||
|
"integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw=="
|
||||||
|
},
|
||||||
|
"node_modules/xml-js": {
|
||||||
|
"version": "1.6.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||||
|
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||||
|
"dependencies": {
|
||||||
|
"sax": "^1.2.4"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"xml-js": "bin/cli.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
710
node_modules/config/History.md
generated
vendored
Normal file
710
node_modules/config/History.md
generated
vendored
Normal file
|
@ -0,0 +1,710 @@
|
||||||
|
Beyond 3.3.7
|
||||||
|
============
|
||||||
|
We've moved this content to [Github Releases](https://github.com/node-config/node-config/releases).
|
||||||
|
|
||||||
|
Future release notes are managed there.
|
||||||
|
|
||||||
|
3.3.7 / 2022-01-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* No new changes. 3.3.6 was not published to NPM in versioning mix-up.
|
||||||
|
* Release notes are moving to Github Releases page going forward.
|
||||||
|
|
||||||
|
3.3.6 / 2021-03-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added publishConfig element to package.json to prevent publishing to the wrong repository - @lorenwest
|
||||||
|
|
||||||
|
3.3.5 / 2021-03-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* FIX [#628](https://github.com/node-config/node-config/issues/628) Uncaught ReferenceError: node_env_var_name is not defined @prnake
|
||||||
|
|
||||||
|
3.3.4 / 2021-02-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* FIX #517 0 loadFileConfigs incorrectly adds to getConfigSources @NguyenMatthieu
|
||||||
|
|
||||||
|
3.3.3 / 2020-11-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* FIX #460 - Strict mode warning refer to appropriate env variable @iCodeOkay
|
||||||
|
* Use Buffer.alloc and Buffer.from instead of contrsuctor @Fcmam5
|
||||||
|
* Add support for experimental .cjs modules @lenkan
|
||||||
|
|
||||||
|
|
||||||
|
3.3.2 / 2020-09-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed issue with Buffers in config throwing error in util.makeImmutable (#608) - Michal Wadas
|
||||||
|
* Added boolean and numeric types to custom environment variables - Ankur Narkhede @ankurnarkhede
|
||||||
|
|
||||||
|
3.3.1 / 2020-03-25
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix security vulnerability in json5 dependency - @twkel
|
||||||
|
|
||||||
|
3.3.0 / 2020-02-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Allow all defined values in `substituteDeep` - @fostyfost
|
||||||
|
|
||||||
|
3.2.6 / 2020-02-21
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Updated copyright date ranges
|
||||||
|
|
||||||
|
3.2.5 / 2020-01-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed issue with getCustomEnvVars and multiple config dirs #585 - @dekelev
|
||||||
|
|
||||||
|
3.2.4 / 2019-10-25
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Improved error handling of env variables value parse - @leonardovillela
|
||||||
|
|
||||||
|
3.2.3 / 2019-10-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed strict mode warning #460 - @fedulovivan
|
||||||
|
|
||||||
|
3.2.2 / 2019-07-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed delimiter bug in configDirs to match O/S delimiter - @iMoses
|
||||||
|
|
||||||
|
3.2.1 / 2019-07-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed TypeError: obj.toString is not a function - @leosuncin
|
||||||
|
|
||||||
|
3.2.0 / 2019-07-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Asynchronous configs - @iMoses
|
||||||
|
* Multiple config directories - @iMoses
|
||||||
|
* Improved parser support - @iMoses
|
||||||
|
|
||||||
|
3.1.0 / 2019-04-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support of module.exports syntax for TS config files @keenondrums
|
||||||
|
|
||||||
|
3.0.1 / 2018-12-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed bug where dot notation extended own key @exogen
|
||||||
|
|
||||||
|
3.0.0 / 2018-11-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Ensure config array items and objects are sealed @fgheorghe
|
||||||
|
- This required a major version bump in case someone
|
||||||
|
- relied on the ability to mutate non-sealed data.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.2 / 2018-08-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added dot notation to setModuleDefaults - bertho-zero
|
||||||
|
* Updated copyright year - JemiloII
|
||||||
|
|
||||||
|
2.0.1 / 2018-07-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Removed deprecated code - jpwilliams
|
||||||
|
|
||||||
|
2.0.0 / 2018-07-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
Potential for backward incompatibility requiring a major version bump.
|
||||||
|
|
||||||
|
Safe to upgrade to major version 2 if you're using a recent NodeJS version
|
||||||
|
and you're not trying to mutate config arrays.
|
||||||
|
|
||||||
|
* Added array immutability - jacobemerick
|
||||||
|
* Removed Node V.4 support
|
||||||
|
|
||||||
|
1.31.0 / 2018-05-22
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Load new coffeescript module instead of coffee-script - bastbijl
|
||||||
|
|
||||||
|
1.30.0 / 2018-02-26
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Support for nested raw() in javascript configurations - patrickpilch
|
||||||
|
|
||||||
|
1.29.4 / 2018-02-03
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Re-publish - last changes didn't make it to npm
|
||||||
|
|
||||||
|
1.29.3 / 2018-02-03
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added soft dependencies so transpilers don't include everything - gewentao
|
||||||
|
|
||||||
|
1.29.2 / 2018-01-12
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Patch, and added a test to ts-node - electroma
|
||||||
|
|
||||||
|
1.29.1 / 2018-01-07
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Prevent re-registration of ts-node - electroma
|
||||||
|
* Fixed bug in contributor table tool - lorenwest
|
||||||
|
|
||||||
|
1.29.0 / 2017-12-26
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Update docs for JavaScript-formatted config files and link them from the README - markstos
|
||||||
|
* Fixed 'hostname' value selection when there is no environment variable for that - wmangelardo
|
||||||
|
|
||||||
|
|
||||||
|
1.28.1 / 2017-11-09
|
||||||
|
===================
|
||||||
|
|
||||||
|
* add nodejs9 to travisci - jfelege
|
||||||
|
|
||||||
|
1.28.0 / 2017-11-07
|
||||||
|
===================
|
||||||
|
|
||||||
|
* allow overrides of `NODE_ENV` with `NODE_CONFIG_ENV` - jfelege
|
||||||
|
|
||||||
|
1.27.0 / 2017-10-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add method to output plain JS object - willsoto
|
||||||
|
* Updated Node versions in Travis CI - lorenwest
|
||||||
|
|
||||||
|
1.26.2 / 2017-08-11
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Update supported nodejs platforms - jfelege
|
||||||
|
|
||||||
|
1.26.1 / 2017-05-03
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix: failed while merging from RegExp @XadillaX
|
||||||
|
* Chore: reduce package size. @evilebottnawi
|
||||||
|
|
||||||
|
1.26.0 / 2017-03-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added tests for extendDeep @IvanVergiliev
|
||||||
|
* Added TypeScript support @cypherq
|
||||||
|
* Update config.js with correctly cased type def @ScionOfBytes
|
||||||
|
|
||||||
|
1.25.1 / 2017-02-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fixed undefined CONFIG_SKIP_GITCRYPT variable @lorenwest
|
||||||
|
|
||||||
|
1.25.0 / 2017-01-31
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add support for configuration files stored with git-crypt @cunneen
|
||||||
|
|
||||||
|
1.24.0 / 2016-11-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Prevent accidental publish to private repository
|
||||||
|
|
||||||
|
1.23.0 / 2016-11-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Re-publishing because npmjs didn't see 1.22
|
||||||
|
|
||||||
|
1.22.0 / 2016-10-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* original/previous value for deferredConfig @simon-scherzinger
|
||||||
|
* util.loadFileConfigs: support optional source dir @wmertens
|
||||||
|
* Adding raw wrapper to prevent object modification in config @patrickpilch
|
||||||
|
|
||||||
|
1.21.0 / 2016-06-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added XML configuration @tusharmath
|
||||||
|
|
||||||
|
1.20.4 / 2016-05-23
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fixed a regression with extending prototype methods @tahoemph
|
||||||
|
|
||||||
|
1.20.3 / 2016-05-18
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fixed a regression with 1.20.2 @kgoerlitz
|
||||||
|
* Added test to prevent this in the future @kgoerlitz
|
||||||
|
|
||||||
|
1.20.2 / 2016-05-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* node v6 compatiblity: remove deprecated __lookupGetter__ use - @thetalecrafter
|
||||||
|
* node v6 compatiblity: handle different SyntaxError format - @pwwolf
|
||||||
|
|
||||||
|
1.20.1 / 2016-04-08
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Simplify truthiness check - @markstos
|
||||||
|
* Remove errant console.log - @markstos
|
||||||
|
|
||||||
|
1.20.0 / 2016-04-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Typo fix @jchip
|
||||||
|
* Handle null sub-object @wmertens
|
||||||
|
* Bug fix for NODE_CONFIG_STRICT_MODE check @markstos
|
||||||
|
* Ran node security check on 4/6/2016 with the following output
|
||||||
|
|
||||||
|
$ nsp check
|
||||||
|
(+) No known vulnerabilities found
|
||||||
|
|
||||||
|
1.19.0 / 2016-01-08
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Resolve defered values in predictable order for consistent results.
|
||||||
|
Fixes #265 @elliotttf @markstos
|
||||||
|
|
||||||
|
1.18.0 / 2015-11-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* More robust handling of JSON @elliotttf
|
||||||
|
|
||||||
|
1.17.1 / 2015-11-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Patch release for regex bugfix
|
||||||
|
|
||||||
|
1.17.0 / 2015-11-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Update warning about missing configuration files to mention how to disable the warning #245 @markstos
|
||||||
|
* Upgrade to run CI with travis containers @lorenwest
|
||||||
|
* Fixed bug with comments and inline json @elliotttf
|
||||||
|
|
||||||
|
1.16.0 / 2015-09-03
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Change == to === to tighten equality tests #242 @wgpsutherland
|
||||||
|
* Fix attachProtoDeep for setModuleDefaults #243 @benkroeger
|
||||||
|
|
||||||
|
1.15.0 / 2015-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added full hostname in addition to first segment @vicary
|
||||||
|
|
||||||
|
1.14.0 / 2015-06-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added JSON parsing to custom environment variables @leachiM2k
|
||||||
|
* Handle unicode BOM characters @johndkane
|
||||||
|
|
||||||
|
1.13.0 / 2015-05-05
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Updated CSON library @dsimidzija
|
||||||
|
|
||||||
|
1.12.0 / 2015-02-19
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Better date merging @axelhzf
|
||||||
|
|
||||||
|
1.11.0 / 2015-01-14
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added Hjson support @laktak
|
||||||
|
|
||||||
|
1.10.0 / 2015-01-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added TOML support (@jasonhansel)
|
||||||
|
* Another year - changed copyright messages for 2015
|
||||||
|
* Updated contributors list
|
||||||
|
* New Strict Mode added in 1.9.0 is now documented. (@markstos)
|
||||||
|
* has() now returns false when given an undefined or null key to look up. Previously it threw an exception. (@markstos)
|
||||||
|
* When get() is given an undefined or null key to look up, it now throws a more helpful diagnostic (@robludwig, @markstos)
|
||||||
|
|
||||||
|
1.9.0 / 2014-12-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* New strictness checks have been added to ensure the expected configuration has been loaded. Warnings are now thrown in these cases. If NODE_CONFIG_STRICT_MODE is set, exceptions are thrown instead. (@markstos)
|
||||||
|
* There must be an explicit config file matching `NODE_ENV` if `NODE_ENV` is set.
|
||||||
|
* There must be an explicit config file matching `NODE_APP_INSTANCE` if `NODE_APP_INSTANCE` is set
|
||||||
|
* `NODE_ENV` must not match 'default' or 'local' to avoid ambiguity.
|
||||||
|
|
||||||
|
* Added .iced extension support (@arthanzel)
|
||||||
|
|
||||||
|
* Highlight `config.has()` in the README. Use it to check to if a value exists, since `config.get()`
|
||||||
|
throws exceptions on undefined values. (@markstos)
|
||||||
|
|
||||||
|
* API Change: getConfigSources() now starts to return data on config files that are valid-but-empty. (@markstos)
|
||||||
|
|
||||||
|
1.8.1 / 2014-11-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Simplify syntax for defer() functions. The 'this' value in the functions is now bound
|
||||||
|
to the main configuration object, so it doesn't have to be passed into the function. (@markstos)
|
||||||
|
* new defer sub-module introduced in 1.8.0 can now be accessed by require('config/defer')
|
||||||
|
For usage, see: https://github.com/node-config/node-config/wiki/Configuration-Files#javascript-module---js
|
||||||
|
* Add test coverage for array merging cases. (@markstos)
|
||||||
|
* Bump dependency on cson package to 1.6.1 (@markstos)
|
||||||
|
|
||||||
|
1.8.0 / 2014-11-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added deferred function for evaluating configs after load (@markstos)
|
||||||
|
For details, see: https://github.com/node-config/node-config/wiki/Configuration-Files#javascript-module---js
|
||||||
|
* Bumped js-yaml dependency (@markstos)
|
||||||
|
|
||||||
|
1.7.0 / 2014-10-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added variable substitution in .properties files (@ncuillery)
|
||||||
|
|
||||||
|
1.6.0 / 2014-10-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for property accessors in configs (@jaylynch)
|
||||||
|
|
||||||
|
1.5.0 / 2014-10-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for .json5 config files (@bertrandom)
|
||||||
|
|
||||||
|
1.4.0 / 2014-10-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for .properties config files (@superoven)
|
||||||
|
|
||||||
|
1.3.0 / 2014-10-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for CSON configuration files (@superoven)
|
||||||
|
|
||||||
|
1.2.4 / 2014-10-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Repaired the 1.2.3 fix to work both before and after the first get()
|
||||||
|
|
||||||
|
1.2.3 / 2014-10-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Changed test suite to verify a bug in util.setModuleDefaults()
|
||||||
|
* Fixed util.setModuleDefaults() to work after a get() (and pass the new test)
|
||||||
|
|
||||||
|
1.2.2 / 2014-10-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for regexp and date configurations (@diversario)
|
||||||
|
|
||||||
|
1.2.1 / 2014-09-23
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Wrote test to prove setModuleDefaults() was broken in 1.2.0
|
||||||
|
* Fixed setModuleDefaults() to not rely on immutable configs
|
||||||
|
|
||||||
|
1.2.0 / 2014-09-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Feature release
|
||||||
|
* Delaying immutability until after first get() - for external configs
|
||||||
|
* Allowing immutability override with $ALLOW_CONFIG_MUTATIONS=Y
|
||||||
|
|
||||||
|
|
||||||
|
1.1.1 / 2014-09-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* @th507 - Update support for Coffee-script >=1.7.0
|
||||||
|
|
||||||
|
1.1.0 / 2014-09-03
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Feature release
|
||||||
|
* @bradboro - Custom environment variables
|
||||||
|
* @supersheep - Catch error when requiring visionmedia yaml module
|
||||||
|
|
||||||
|
1.0.2 / 2014-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* @bradobro - Fixed a variable from leaking into global
|
||||||
|
* @tilfin - Removed un-necessary YAML comment filtering for js-yaml
|
||||||
|
|
||||||
|
1.0.1 / 2014-07-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Removed test directory from npm install
|
||||||
|
|
||||||
|
1.0.0 / 2014-07-23
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Major revision. Upgrade notes:
|
||||||
|
https://github.com/node-config/node-config/wiki/Upgrading-From-Config-0.x
|
||||||
|
* Update to semver versioning
|
||||||
|
* Change load ordering
|
||||||
|
from hostname.EXT --> deployment.EXT
|
||||||
|
to deployment.EXT --> hostname.EXT
|
||||||
|
* Allow makeImmutable to accept an array of attributes
|
||||||
|
* Allow makeImmutable to accept no attrs, making all attributes immutable
|
||||||
|
* Allow recursion in makeImmutable, if an attribute is an object
|
||||||
|
* Change node-config behavior to make all configurations immutable
|
||||||
|
* Removed getOriginalConfig as no longer necessary post-immutable
|
||||||
|
* Removed runtime.json file writing and monitoring
|
||||||
|
* Removed previously deprecated $CONFIG_* environment configurations
|
||||||
|
* Deprecated the attribute watch functionality
|
||||||
|
* Added error output if no configurations found
|
||||||
|
* Exposed config loading for alternate configurations
|
||||||
|
* Added config.get() and config.has() methods & tests
|
||||||
|
* Removed reliance on global.NODE_CONFIG so older versions can work with 1.x
|
||||||
|
* Fix empty YAML file causing crash with latest js-yaml
|
||||||
|
* Added SUPPRESS_NO_CONFIG_WARNING for better sub-module support
|
||||||
|
* Moved all documentation [to the wiki](https://github.com/node-config/node-config/wiki).
|
||||||
|
|
||||||
|
0.4.37 / 2014-07-22
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix empty YAML file causing crash with latest js-yaml
|
||||||
|
|
||||||
|
0.4.36 / 2014-05-27
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Not writing runtime.json if not used
|
||||||
|
|
||||||
|
0.4.35 / 2014-01-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* NODE_CONFIG_DIR can now contain a relative path for .js and .coffee configurations
|
||||||
|
|
||||||
|
0.4.34 / 2014-01-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Updated copyright year
|
||||||
|
|
||||||
|
0.4.33 / 2013-10-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Assure writes to runtime.json are atomic
|
||||||
|
|
||||||
|
0.4.32 / 2013-10-24
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Don't freak out if running without a config directory
|
||||||
|
* Don't be so chatty if runtime.json doesn't exist
|
||||||
|
|
||||||
|
0.4.31 / 2013-10-18
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Changed getConfigSources to copy array vs. object
|
||||||
|
|
||||||
|
0.4.30 / 2013-09-12
|
||||||
|
===================
|
||||||
|
|
||||||
|
* More consistent array extension
|
||||||
|
* No longer requiring a config directory
|
||||||
|
* Not erroneously writing runtime.json
|
||||||
|
* Exposing the original configuration sources
|
||||||
|
* Added --NODE_CONFIG={json} command line overrides
|
||||||
|
* Added $NODE_CONFIG={json} environment variable overrides
|
||||||
|
* Consistent handling of environment variables and command line parameters
|
||||||
|
* Reached 100 regression tests
|
||||||
|
|
||||||
|
0.4.29 / 2013-08-07
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added flag for disabling the write of runtime.json
|
||||||
|
|
||||||
|
0.4.28 / 2013-07-31
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Eliminated a totally annoying install warning in newer versions of NPM
|
||||||
|
|
||||||
|
0.4.27 / 2013-06-18
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fixed a bug preventing double underscores in config environment variables
|
||||||
|
|
||||||
|
0.4.26 / 2013-06-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Re-watch file on rename (allows editing runtime.json with vi)
|
||||||
|
* Allow runtime.json file watch disable via NODE_CONFIG_DISABLE_FILE_WATCH=Y
|
||||||
|
* Change no yaml parser error message to suggest using js-yaml
|
||||||
|
* Changed default clone depth from 6 to 20 to allow for deeper configurations
|
||||||
|
|
||||||
|
0.4.25 / 2013-05-24
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Dont fail if config directory doesnt exist
|
||||||
|
|
||||||
|
0.4.24 / 2013-04-13
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added resetRuntime() to reset the runtime.json file
|
||||||
|
* Updated docs to reflect the new public method
|
||||||
|
|
||||||
|
0.4.23 / 2013-04-13
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Multiple application instance support via $NODE_APP_INSTANCE
|
||||||
|
* Multi-app testing & documentation
|
||||||
|
|
||||||
|
0.4.22 / 2013-03-29
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added configuration $CONFIG_* environment variables
|
||||||
|
* Added $CONFIG_* documentation and tests
|
||||||
|
* Added NodeJS 0.10 integration test
|
||||||
|
|
||||||
|
0.4.21 / 2013-03-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Triggering file.watch when an editor saves a file - rename vs. change
|
||||||
|
* Installed Travis-CI continuous integration testing framework
|
||||||
|
|
||||||
|
0.4.20 / 2013-02-21
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Merged _diffDeep fix
|
||||||
|
|
||||||
|
0.4.19 / 2013-02-21
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added discovery of .yml in addition to .yaml for YAML configs (w/doc)
|
||||||
|
* Added testing of .yml file discovery
|
||||||
|
* Removed licensing inconsistencies
|
||||||
|
|
||||||
|
0.4.18 / 2012-10-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Moved coffee-script and js-yaml from optionalDependencies back to
|
||||||
|
devDependencies to trim the install size for those not needing
|
||||||
|
these packages.
|
||||||
|
* Promoted $HOSTNAME and $HOST above OS.hostname()
|
||||||
|
|
||||||
|
0.4.17 / 2012-09-26
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Allow the location of runtime.json to be picked up from the environment
|
||||||
|
* Added documentation for the NODE_CONFIG_RUNTIME_JSON environment variable
|
||||||
|
* package.json cleanup - created optionalDependencies and devDependencies
|
||||||
|
|
||||||
|
0.4.16 / 2012-08-09
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Allowing a zero interval in watchForConfigFileChanges() to disable file watching.
|
||||||
|
* Fixed a comparator bug in _equalsDeep()
|
||||||
|
* Added a test to confirm deep extending array functionality
|
||||||
|
|
||||||
|
0.4.15 / 2012-06-04
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Placed YAML and Coffee-Script libraries back into the download. Still lazy loading into memory.
|
||||||
|
|
||||||
|
0.4.14 / 2012-06-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Added the local.EXT and local-deployment.EXT configs.
|
||||||
|
* Removed unnecessary debug output
|
||||||
|
* Added retry logic on file parse to reduce read/write collisions
|
||||||
|
* Added support for a better YAML parser
|
||||||
|
* Fixed problems with null configuration values
|
||||||
|
|
||||||
|
0.4.13 / 2012-04-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Assuring the runtime.json file exists. Undocumented fs.watch() requirement.
|
||||||
|
|
||||||
|
0.4.12 / 2012-04-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Removed all external dependencies
|
||||||
|
* Lazy loading of yaml and coffee-script only if these file types are used
|
||||||
|
* Added new style file watching if available (retaining pre 6.0 compatibility)
|
||||||
|
* Windows compatibility - file watching changes were required
|
||||||
|
|
||||||
|
0.4.11 / 2012-02-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Automatically watching runtime.json for changes
|
||||||
|
* Fixed a date comparison bug during file watching
|
||||||
|
* Changed require('sys') to require('util')
|
||||||
|
|
||||||
|
0.4.10 / 2012-01-18
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Made sure the CONFIG object is a shared singleton
|
||||||
|
* Added NODE_CONFIG_DIR environment variable to point to a different directory
|
||||||
|
* Added tests and documentation for the above
|
||||||
|
|
||||||
|
0.4.9 / 2012-01-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added coffee-script file type support with extension .coffee
|
||||||
|
* Added an example coffee-script configuration file
|
||||||
|
* Added coffee-script module dependency
|
||||||
|
* Added a test for coffee-script configuration files
|
||||||
|
* Documented coffee-script support, regenerated documentation
|
||||||
|
|
||||||
|
0.4.8 / 2011-12-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed a bug where changes to module default configs weren't persisted
|
||||||
|
* Added a test to validate the bugfix
|
||||||
|
|
||||||
|
0.4.7 / 2011-12-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Created the makeHidden method to hide a property of an object
|
||||||
|
* Added a value argument to makeImmutable for creating new properties
|
||||||
|
* Fixed setModuleDefaults to hide injected prototype methods
|
||||||
|
* Added documentation and unit tests
|
||||||
|
|
||||||
|
0.4.6 / 2011-11-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Updated vows from 0.5.8 to 0.5.13
|
||||||
|
|
||||||
|
0.4.5 / 2011-11-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Updated YAML dependency from "0.1.x" to ">=0.2.2"
|
||||||
|
* Added stripping of comment-only and whitespace-only lines in YAML files for backward compatibility
|
||||||
|
* Added more tests for YAML edge cases
|
||||||
|
* Added a homepage link in package.json to the online documentation
|
||||||
|
* Added History.md
|
||||||
|
|
||||||
|
0.4.4 / 2011-11-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Removed deprecated modules from package.json
|
||||||
|
|
||||||
|
0.4.3 / 2011-08-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Made watchForConfigFileChanges public
|
||||||
|
|
||||||
|
0.4.2 / 2011-07-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added comment stripping from JSON configuration files
|
||||||
|
|
||||||
|
0.4.1 / 2011-07-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added more tests
|
||||||
|
* Return the module config in setModuleDefaults
|
||||||
|
|
||||||
|
0.4.0 / 2011-07-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Update to version 0.4.0
|
||||||
|
|
||||||
|
* Online documentation
|
||||||
|
* Runtime configuration changes
|
||||||
|
* Configuration value watching
|
||||||
|
* Multi-instance node deployments
|
||||||
|
* Better module developer support
|
19
node_modules/config/LICENSE
generated
vendored
Normal file
19
node_modules/config/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2010-2022, Loren West and other contributors
|
||||||
|
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
176
node_modules/config/README.md
generated
vendored
Normal file
176
node_modules/config/README.md
generated
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
Configure your Node.js Applications
|
||||||
|
===================================
|
||||||
|
|
||||||
|
[![NPM](https://nodei.co/npm/config.svg?downloads=true&downloadRank=true)](https://nodei.co/npm/config/)
|
||||||
|
[![Build Status](https://secure.travis-ci.org/node-config/node-config.svg?branch=master)](https://travis-ci.org/lorenwest/node-config)
|
||||||
|
[release notes](https://github.com/node-config/node-config/blob/master/History.md)
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
Node-config organizes hierarchical configurations for your app deployments.
|
||||||
|
|
||||||
|
It lets you define a set of default parameters,
|
||||||
|
and extend them for different deployment environments (development, qa,
|
||||||
|
staging, production, etc.).
|
||||||
|
|
||||||
|
Configurations are stored in [configuration files](https://github.com/node-config/node-config/wiki/Configuration-Files) within your application, and can be overridden and extended by [environment variables](https://github.com/lorenwest/node-config/wiki/Environment-Variables),
|
||||||
|
[command line parameters](https://github.com/node-config/node-config/wiki/Command-Line-Overrides), or [external sources](https://github.com/lorenwest/node-config/wiki/Configuring-from-an-External-Source).
|
||||||
|
|
||||||
|
This gives your application a consistent configuration interface shared among a
|
||||||
|
[growing list of npm modules](https://www.npmjs.org/browse/depended/config) also using node-config.
|
||||||
|
|
||||||
|
Project Guidelines
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* *Simple* - Get started fast
|
||||||
|
* *Powerful* - For multi-node enterprise deployment
|
||||||
|
* *Flexible* - Supporting multiple config file formats
|
||||||
|
* *Lightweight* - Small file and memory footprint
|
||||||
|
* *Predictable* - Well tested foundation for module and app developers
|
||||||
|
|
||||||
|
Quick Start
|
||||||
|
---------------
|
||||||
|
The following examples are in JSON format, but configurations can be in other [file formats](https://github.com/node-config/node-config/wiki/Configuration-Files#file-formats).
|
||||||
|
|
||||||
|
**Install in your app directory, and edit the default config file.**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ npm install config
|
||||||
|
$ mkdir config
|
||||||
|
$ vi config/default.json
|
||||||
|
```
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
// Customer module configs
|
||||||
|
"Customer": {
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5984,
|
||||||
|
"dbName": "customers"
|
||||||
|
},
|
||||||
|
"credit": {
|
||||||
|
"initialLimit": 100,
|
||||||
|
// Set low for development
|
||||||
|
"initialDays": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Edit config overrides for production deployment:**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ vi config/production.json
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Customer": {
|
||||||
|
"dbConfig": {
|
||||||
|
"host": "prod-db-server"
|
||||||
|
},
|
||||||
|
"credit": {
|
||||||
|
"initialDays": 30
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Use configs in your code:**
|
||||||
|
|
||||||
|
```js
|
||||||
|
const config = require('config');
|
||||||
|
//...
|
||||||
|
const dbConfig = config.get('Customer.dbConfig');
|
||||||
|
db.connect(dbConfig, ...);
|
||||||
|
|
||||||
|
if (config.has('optionalFeature.detail')) {
|
||||||
|
const detail = config.get('optionalFeature.detail');
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`config.get()` will throw an exception for undefined keys to help catch typos and missing values.
|
||||||
|
Use `config.has()` to test if a configuration value is defined.
|
||||||
|
|
||||||
|
**Start your app server:**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ export NODE_ENV=production
|
||||||
|
$ node my-app.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Running in this configuration, the `port` and `dbName` elements of `dbConfig`
|
||||||
|
will come from the `default.json` file, and the `host` element will
|
||||||
|
come from the `production.json` override file.
|
||||||
|
|
||||||
|
Articles
|
||||||
|
--------
|
||||||
|
|
||||||
|
* [Configuration Files](https://github.com/node-config/node-config/wiki/Configuration-Files)
|
||||||
|
* [Special features for JavaScript configuration files](https://github.com/node-config/node-config/wiki/Special-features-for-JavaScript-configuration-files)
|
||||||
|
* [Common Usage](https://github.com/node-config/node-config/wiki/Common-Usage)
|
||||||
|
* [Environment Variables](https://github.com/node-config/node-config/wiki/Environment-Variables)
|
||||||
|
* [Reserved Words](https://github.com/node-config/node-config/wiki/Reserved-Words)
|
||||||
|
* [Command Line Overrides](https://github.com/node-config/node-config/wiki/Command-Line-Overrides)
|
||||||
|
* [Multiple Node Instances](https://github.com/node-config/node-config/wiki/Multiple-Node-Instances)
|
||||||
|
* [Sub-Module Configuration](https://github.com/node-config/node-config/wiki/Sub-Module-Configuration)
|
||||||
|
* [Configuring from a DB / External Source](https://github.com/node-config/node-config/wiki/Configuring-from-an-External-Source)
|
||||||
|
* [Securing Production Config Files](https://github.com/node-config/node-config/wiki/Securing-Production-Config-Files)
|
||||||
|
* [External Configuration Management Tools](https://github.com/node-config/node-config/wiki/External-Configuration-Management-Tools)
|
||||||
|
* [Examining Configuration Sources](https://github.com/node-config/node-config/wiki/Examining-Configuration-Sources)
|
||||||
|
* [Using Config Utilities](https://github.com/node-config/node-config/wiki/Using-Config-Utilities)
|
||||||
|
* [Upgrading from Config 0.x](https://github.com/node-config/node-config/wiki/Upgrading-From-Config-0.x)
|
||||||
|
* [Webpack usage](https://github.com/node-config/node-config/wiki/Webpack-Usage)
|
||||||
|
|
||||||
|
Further Information
|
||||||
|
---------------------
|
||||||
|
If you still don't see what you are looking for, here are some more resources to check:
|
||||||
|
|
||||||
|
* The [wiki may have more pages](https://github.com/node-config/node-config/wiki) which are not directly linked from here.
|
||||||
|
* Review [questions tagged with node-config](https://stackexchange.com/filters/207096/node-config) on StackExchange. These are monitored by `node-config` contributors.
|
||||||
|
* [Search the issue tracker](https://github.com/node-config/node-config/issues). Hundreds of issues have already been discussed and resolved there.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
<table id="contributors"><tr><td><img src=https://avatars.githubusercontent.com/u/373538?v=4><a href="https://github.com/lorenwest">lorenwest</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1083065?v=4><a href="https://github.com/iMoses">iMoses</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/447151?v=4><a href="https://github.com/elliotttf">elliotttf</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachiM2k</a></td>
|
||||||
|
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/791137?v=4><a href="https://github.com/josx">josx</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/4307697?v=4><a href="https://github.com/leosuncin">leosuncin</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1077378?v=4><a href="https://github.com/arthanzel">arthanzel</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
|
||||||
|
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1751645?v=4><a href="https://github.com/cunneen">cunneen</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">BadgerBadgerBadgerBadger</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
|
||||||
|
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/175627?v=4><a href="https://github.com/axelhzf">axelhzf</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/7782055?v=4><a href="https://github.com/benkroeger">benkroeger</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1443067?v=4><a href="https://github.com/IvanVergiliev">IvanVergiliev</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1736957?v=4><a href="https://github.com/jpwilliams">jpwilliams</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
|
||||||
|
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/8525267?v=4><a href="https://github.com/bertho-zero">bertho-zero</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/6686044?v=4><a href="https://github.com/NguyenMatthieu">NguyenMatthieu</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
|
||||||
|
<td><img src=https://avatars.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
|
||||||
|
</tr></table>
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
May be freely distributed under the [MIT license](https://raw.githubusercontent.com/node-config/node-config/master/LICENSE).
|
||||||
|
|
||||||
|
Copyright (c) 2010-2022 Loren West
|
||||||
|
[and other contributors](https://github.com/node-config/node-config/graphs/contributors)
|
||||||
|
|
70
node_modules/config/async.js
generated
vendored
Normal file
70
node_modules/config/async.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
var asyncSymbol = Symbol('asyncSymbol');
|
||||||
|
var deferConfig = require('./defer').deferConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param promiseOrFunc the promise will determine a property's value once resolved
|
||||||
|
* can also be a function to defer which resolves to a promise
|
||||||
|
* @returns {Promise} a marked promise to be resolve later using `resolveAsyncConfigs`
|
||||||
|
*/
|
||||||
|
function asyncConfig(promiseOrFunc) {
|
||||||
|
if (typeof promiseOrFunc === 'function') { // also acts as deferConfig
|
||||||
|
return deferConfig(function (config, original) {
|
||||||
|
var release;
|
||||||
|
function registerRelease(resolve) { release = resolve; }
|
||||||
|
function callFunc() { return promiseOrFunc.call(config, config, original); }
|
||||||
|
var promise = asyncConfig(new Promise(registerRelease).then(callFunc));
|
||||||
|
promise.release = release;
|
||||||
|
return promise;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var promise = promiseOrFunc;
|
||||||
|
promise.async = asyncSymbol;
|
||||||
|
promise.prepare = function(config, prop, property) {
|
||||||
|
if (promise.release) {
|
||||||
|
promise.release();
|
||||||
|
}
|
||||||
|
return function() {
|
||||||
|
return promise.then(function(value) {
|
||||||
|
Object.defineProperty(prop, property, {value: value});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use `config.get` before executing this method, it will freeze the config object
|
||||||
|
* @param config the main config object, returned from require('config')
|
||||||
|
* @returns {Promise<config>} once all promises are resolved, return the original config object
|
||||||
|
*/
|
||||||
|
function resolveAsyncConfigs(config) {
|
||||||
|
var promises = [];
|
||||||
|
var resolvers = [];
|
||||||
|
(function iterate(prop) {
|
||||||
|
var propsToSort = [];
|
||||||
|
for (var property in prop) {
|
||||||
|
if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) {
|
||||||
|
propsToSort.push(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
propsToSort.sort().forEach(function(property) {
|
||||||
|
if (prop[property].constructor === Object) {
|
||||||
|
iterate(prop[property]);
|
||||||
|
}
|
||||||
|
else if (prop[property].constructor === Array) {
|
||||||
|
prop[property].forEach(iterate);
|
||||||
|
}
|
||||||
|
else if (prop[property] && prop[property].async === asyncSymbol) {
|
||||||
|
resolvers.push(prop[property].prepare(config, prop, property));
|
||||||
|
promises.push(prop[property]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(config);
|
||||||
|
return Promise.all(promises).then(function() {
|
||||||
|
resolvers.forEach(function(resolve) { resolve(); });
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.asyncConfig = asyncConfig;
|
||||||
|
module.exports.resolveAsyncConfigs = resolveAsyncConfigs;
|
23
node_modules/config/defer.js
generated
vendored
Normal file
23
node_modules/config/defer.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// Create a deferredConfig prototype so that we can check for it when reviewing the configs later.
|
||||||
|
function DeferredConfig() {}
|
||||||
|
DeferredConfig.prototype.prepare = function() {};
|
||||||
|
DeferredConfig.prototype.resolve = function() {};
|
||||||
|
|
||||||
|
// Accept a function that we'll use to resolve this value later and return a 'deferred' configuration value to resolve it later.
|
||||||
|
function deferConfig(func) {
|
||||||
|
var obj = Object.create(DeferredConfig.prototype);
|
||||||
|
obj.prepare = function(config, prop, property) {
|
||||||
|
var original = prop[property]._original;
|
||||||
|
obj.resolve = function() {
|
||||||
|
var value = func.call(config, config, original);
|
||||||
|
Object.defineProperty(prop, property, {value: value});
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
Object.defineProperty(prop, property, {get: function() { return obj.resolve(); }});
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.deferConfig = deferConfig;
|
||||||
|
module.exports.DeferredConfig = DeferredConfig;
|
1521
node_modules/config/lib/config.js
generated
vendored
Normal file
1521
node_modules/config/lib/config.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
52
node_modules/config/package.json
generated
vendored
Normal file
52
node_modules/config/package.json
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
"name": "config",
|
||||||
|
"version": "3.3.9",
|
||||||
|
"main": "./lib/config.js",
|
||||||
|
"description": "Configuration control for production node deployments",
|
||||||
|
"author": "Loren West <open_source@lorenwest.com>",
|
||||||
|
"homepage": "http://github.com/node-config/node-config.git",
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://registry.npmjs.org/"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"conf",
|
||||||
|
"config",
|
||||||
|
"configuration",
|
||||||
|
"node-config",
|
||||||
|
"config-node",
|
||||||
|
"env",
|
||||||
|
"environment"
|
||||||
|
],
|
||||||
|
"directories": {
|
||||||
|
"lib": "./lib"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"json5": "^2.2.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^7.0.8",
|
||||||
|
"coffeescript": "2.2.4",
|
||||||
|
"cson": "^3.0.1",
|
||||||
|
"hjson": "^1.2.0",
|
||||||
|
"js-yaml": "^3.2.2",
|
||||||
|
"properties": "~1.2.1",
|
||||||
|
"semver": "5.3.0",
|
||||||
|
"toml": "^2.0.6",
|
||||||
|
"ts-node": "^3.3.0",
|
||||||
|
"typescript": "^2.4.2",
|
||||||
|
"underscore": "^1.8.3",
|
||||||
|
"vows": ">=0.8.1",
|
||||||
|
"x2js": "^2.0.1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://github.com/node-config/node-config.git"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "./node_modules/vows/bin/vows test/*.js --spec"
|
||||||
|
}
|
||||||
|
}
|
368
node_modules/config/parser.js
generated
vendored
Normal file
368
node_modules/config/parser.js
generated
vendored
Normal file
|
@ -0,0 +1,368 @@
|
||||||
|
// External libraries are lazy-loaded only if these file types exist.
|
||||||
|
const util = require("util");
|
||||||
|
var Yaml = null,
|
||||||
|
VisionmediaYaml = null,
|
||||||
|
Coffee = null,
|
||||||
|
Iced = null,
|
||||||
|
CSON = null,
|
||||||
|
PPARSER = null,
|
||||||
|
JSON5 = null,
|
||||||
|
TOML = null,
|
||||||
|
HJSON = null,
|
||||||
|
XML = null;
|
||||||
|
|
||||||
|
// Define soft dependencies so transpilers don't include everything
|
||||||
|
var COFFEE_2_DEP = 'coffeescript',
|
||||||
|
COFFEE_DEP = 'coffee-script',
|
||||||
|
ICED_DEP = 'iced-coffee-script',
|
||||||
|
JS_YAML_DEP = 'js-yaml',
|
||||||
|
YAML_DEP = 'yaml',
|
||||||
|
JSON5_DEP = 'json5',
|
||||||
|
HJSON_DEP = 'hjson',
|
||||||
|
TOML_DEP = 'toml',
|
||||||
|
CSON_DEP = 'cson',
|
||||||
|
PPARSER_DEP = 'properties',
|
||||||
|
XML_DEP = 'x2js',
|
||||||
|
TS_DEP = 'ts-node';
|
||||||
|
|
||||||
|
var Parser = module.exports;
|
||||||
|
|
||||||
|
Parser.parse = function(filename, content) {
|
||||||
|
var parserName = filename.substr(filename.lastIndexOf('.') +1); // file extension
|
||||||
|
if (typeof definitions[parserName] === 'function') {
|
||||||
|
return definitions[parserName](filename, content);
|
||||||
|
}
|
||||||
|
// TODO: decide what to do in case of a missing parser
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.xmlParser = function(filename, content) {
|
||||||
|
if (!XML) {
|
||||||
|
XML = require(XML_DEP);
|
||||||
|
}
|
||||||
|
var x2js = new XML();
|
||||||
|
var configObject = x2js.xml2js(content);
|
||||||
|
var rootKeys = Object.keys(configObject);
|
||||||
|
if(rootKeys.length === 1) {
|
||||||
|
return configObject[rootKeys[0]];
|
||||||
|
}
|
||||||
|
return configObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.jsParser = function(filename, content) {
|
||||||
|
var configObject = require(filename);
|
||||||
|
|
||||||
|
if (configObject.__esModule && util.isObject(configObject.default)) {
|
||||||
|
return configObject.default
|
||||||
|
}
|
||||||
|
return configObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.tsParser = function(filename, content) {
|
||||||
|
if (!require.extensions['.ts']) {
|
||||||
|
require(TS_DEP).register({
|
||||||
|
lazy: true,
|
||||||
|
transpileOnly: true,
|
||||||
|
compilerOptions: {
|
||||||
|
allowJs: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Imports config if it is exported via module.exports = ...
|
||||||
|
// See https://github.com/node-config/node-config/issues/524
|
||||||
|
var configObject = require(filename);
|
||||||
|
|
||||||
|
// Because of ES6 modules usage, `default` is treated as named export (like any other)
|
||||||
|
// Therefore config is a value of `default` key.
|
||||||
|
if (configObject.default) {
|
||||||
|
return configObject.default
|
||||||
|
}
|
||||||
|
return configObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.coffeeParser = function(filename, content) {
|
||||||
|
// .coffee files can be loaded with either coffee-script or iced-coffee-script.
|
||||||
|
// Prefer iced-coffee-script, if it exists.
|
||||||
|
// Lazy load the appropriate extension
|
||||||
|
if (!Coffee) {
|
||||||
|
Coffee = {};
|
||||||
|
|
||||||
|
// The following enables iced-coffee-script on .coffee files, if iced-coffee-script is available.
|
||||||
|
// This is commented as per a decision on a pull request.
|
||||||
|
//try {
|
||||||
|
// Coffee = require('iced-coffee-script');
|
||||||
|
//}
|
||||||
|
//catch (e) {
|
||||||
|
// Coffee = require('coffee-script');
|
||||||
|
//}
|
||||||
|
try {
|
||||||
|
// Try to load coffeescript
|
||||||
|
Coffee = require(COFFEE_2_DEP);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// If it doesn't exist, try to load it using the deprecated module name
|
||||||
|
Coffee = require(COFFEE_DEP);
|
||||||
|
}
|
||||||
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
||||||
|
if (Coffee.register) {
|
||||||
|
Coffee.register();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use the built-in parser for .coffee files with coffee-script
|
||||||
|
return require(filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.icedParser = function(filename, content) {
|
||||||
|
Iced = require(ICED_DEP);
|
||||||
|
|
||||||
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
||||||
|
if (Iced.register) {
|
||||||
|
Iced.register();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.yamlParser = function(filename, content) {
|
||||||
|
if (!Yaml && !VisionmediaYaml) {
|
||||||
|
// Lazy loading
|
||||||
|
try {
|
||||||
|
// Try to load the better js-yaml module
|
||||||
|
Yaml = require(JS_YAML_DEP);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
try {
|
||||||
|
// If it doesn't exist, load the fallback visionmedia yaml module.
|
||||||
|
VisionmediaYaml = require(YAML_DEP);
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Yaml) {
|
||||||
|
return Yaml.load(content);
|
||||||
|
}
|
||||||
|
else if (VisionmediaYaml) {
|
||||||
|
// The yaml library doesn't like strings that have newlines but don't
|
||||||
|
// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
|
||||||
|
content += '\n';
|
||||||
|
if (typeof VisionmediaYaml.eval === 'function') {
|
||||||
|
return VisionmediaYaml.eval(Parser.stripYamlComments(content));
|
||||||
|
}
|
||||||
|
return VisionmediaYaml.parse(Parser.stripYamlComments(content));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error('No YAML parser loaded. Suggest adding js-yaml dependency to your package.json file.')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.jsonParser = function(filename, content) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(content);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// All JS Style comments will begin with /, so all JSON parse errors that
|
||||||
|
// encountered a syntax error will complain about this character.
|
||||||
|
if (e.name !== 'SyntaxError' || e.message.indexOf('Unexpected token /') !== 0) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
if (!JSON5) {
|
||||||
|
JSON5 = require(JSON5_DEP);
|
||||||
|
}
|
||||||
|
return JSON5.parse(content);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.json5Parser = function(filename, content) {
|
||||||
|
if (!JSON5) {
|
||||||
|
JSON5 = require(JSON5_DEP);
|
||||||
|
}
|
||||||
|
return JSON5.parse(content);
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.hjsonParser = function(filename, content) {
|
||||||
|
if (!HJSON) {
|
||||||
|
HJSON = require(HJSON_DEP);
|
||||||
|
}
|
||||||
|
return HJSON.parse(content);
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.tomlParser = function(filename, content) {
|
||||||
|
if(!TOML) {
|
||||||
|
TOML = require(TOML_DEP);
|
||||||
|
}
|
||||||
|
return TOML.parse(content);
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.csonParser = function(filename, content) {
|
||||||
|
if (!CSON) {
|
||||||
|
CSON = require(CSON_DEP);
|
||||||
|
}
|
||||||
|
// Allow comments in CSON files
|
||||||
|
if (typeof CSON.parseSync === 'function') {
|
||||||
|
return CSON.parseSync(Parser.stripComments(content));
|
||||||
|
}
|
||||||
|
return CSON.parse(Parser.stripComments(content));
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.propertiesParser = function(filename, content) {
|
||||||
|
if (!PPARSER) {
|
||||||
|
PPARSER = require(PPARSER_DEP);
|
||||||
|
}
|
||||||
|
return PPARSER.parse(content, { namespaces: true, variables: true, sections: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip all Javascript type comments from the string.
|
||||||
|
*
|
||||||
|
* The string is usually a file loaded from the O/S, containing
|
||||||
|
* newlines and javascript type comments.
|
||||||
|
*
|
||||||
|
* Thanks to James Padolsey, and all who contributed to this implementation.
|
||||||
|
* http://james.padolsey.com/javascript/javascript-comment-removal-revisted/
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @method stripComments
|
||||||
|
* @param fileStr {string} The string to strip comments from
|
||||||
|
* @param stringRegex {RegExp} Optional regular expression to match strings that
|
||||||
|
* make up the config file
|
||||||
|
* @return {string} The string with comments stripped.
|
||||||
|
*/
|
||||||
|
Parser.stripComments = function(fileStr, stringRegex) {
|
||||||
|
stringRegex = stringRegex || /(['"])(\\\1|.)+?\1/g;
|
||||||
|
|
||||||
|
var uid = '_' + +new Date(),
|
||||||
|
primitives = [],
|
||||||
|
primIndex = 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
fileStr
|
||||||
|
|
||||||
|
/* Remove strings */
|
||||||
|
.replace(stringRegex, function(match){
|
||||||
|
primitives[primIndex] = match;
|
||||||
|
return (uid + '') + primIndex++;
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Remove Regexes */
|
||||||
|
.replace(/([^\/])(\/(?!\*|\/)(\\\/|.)+?\/[gim]{0,3})/g, function(match, $1, $2){
|
||||||
|
primitives[primIndex] = $2;
|
||||||
|
return $1 + (uid + '') + primIndex++;
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
- Remove single-line comments that contain would-be multi-line delimiters
|
||||||
|
E.g. // Comment /* <--
|
||||||
|
- Remove multi-line comments that contain would be single-line delimiters
|
||||||
|
E.g. /* // <--
|
||||||
|
*/
|
||||||
|
.replace(/\/\/.*?\/?\*.+?(?=\n|\r|$)|\/\*[\s\S]*?\/\/[\s\S]*?\*\//g, '')
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove single and multi-line comments,
|
||||||
|
no consideration of inner-contents
|
||||||
|
*/
|
||||||
|
.replace(/\/\/.+?(?=\n|\r|$)|\/\*[\s\S]+?\*\//g, '')
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove multi-line comments that have a replaced ending (string/regex)
|
||||||
|
Greedy, so no inner strings/regexes will stop it.
|
||||||
|
*/
|
||||||
|
.replace(RegExp('\\/\\*[\\s\\S]+' + uid + '\\d+', 'g'), '')
|
||||||
|
|
||||||
|
/* Bring back strings & regexes */
|
||||||
|
.replace(RegExp(uid + '(\\d+)', 'g'), function(match, n){
|
||||||
|
return primitives[n];
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip YAML comments from the string
|
||||||
|
*
|
||||||
|
* The 2.0 yaml parser doesn't allow comment-only or blank lines. Strip them.
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @method stripYamlComments
|
||||||
|
* @param fileStr {string} The string to strip comments from
|
||||||
|
* @return {string} The string with comments stripped.
|
||||||
|
*/
|
||||||
|
Parser.stripYamlComments = function(fileStr) {
|
||||||
|
// First replace removes comment-only lines
|
||||||
|
// Second replace removes blank lines
|
||||||
|
return fileStr.replace(/^\s*#.*/mg,'').replace(/^\s*[\n|\r]+/mg,'');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the environment variable to the boolean equivalent.
|
||||||
|
* Defaults to false
|
||||||
|
*
|
||||||
|
* @param {String} content - Environment variable value
|
||||||
|
* @return {boolean} - Boolean value fo the passed variable value
|
||||||
|
*/
|
||||||
|
Parser.booleanParser = function(filename, content) {
|
||||||
|
return content === 'true';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the environment variable to the number equivalent.
|
||||||
|
* Defaults to undefined
|
||||||
|
*
|
||||||
|
* @param {String} content - Environment variable value
|
||||||
|
* @return {Number} - Number value fo the passed variable value
|
||||||
|
*/
|
||||||
|
Parser.numberParser = function(filename, content) {
|
||||||
|
const numberValue = Number(content);
|
||||||
|
return Number.isNaN(numberValue) ? undefined : numberValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
var order = ['js', 'cjs', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
||||||
|
'boolean', 'number'];
|
||||||
|
var definitions = {
|
||||||
|
cjs: Parser.jsParser,
|
||||||
|
coffee: Parser.coffeeParser,
|
||||||
|
cson: Parser.csonParser,
|
||||||
|
hjson: Parser.hjsonParser,
|
||||||
|
iced: Parser.icedParser,
|
||||||
|
js: Parser.jsParser,
|
||||||
|
json: Parser.jsonParser,
|
||||||
|
json5: Parser.json5Parser,
|
||||||
|
properties: Parser.propertiesParser,
|
||||||
|
toml: Parser.tomlParser,
|
||||||
|
ts: Parser.tsParser,
|
||||||
|
xml: Parser.xmlParser,
|
||||||
|
yaml: Parser.yamlParser,
|
||||||
|
yml: Parser.yamlParser,
|
||||||
|
boolean: Parser.booleanParser,
|
||||||
|
number: Parser.numberParser
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.getParser = function(name) {
|
||||||
|
return definitions[name];
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.setParser = function(name, parser) {
|
||||||
|
definitions[name] = parser;
|
||||||
|
if (order.indexOf(name) === -1) {
|
||||||
|
order.push(name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.getFilesOrder = function(name) {
|
||||||
|
if (name) {
|
||||||
|
return order.indexOf(name);
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
};
|
||||||
|
|
||||||
|
Parser.setFilesOrder = function(name, newIndex) {
|
||||||
|
if (Array.isArray(name)) {
|
||||||
|
return order = name;
|
||||||
|
}
|
||||||
|
if (typeof newIndex === 'number') {
|
||||||
|
var index = order.indexOf(name);
|
||||||
|
order.splice(newIndex, 0, name);
|
||||||
|
if (index > -1) {
|
||||||
|
order.splice(index >= newIndex ? index +1 : index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
};
|
15
node_modules/config/raw.js
generated
vendored
Normal file
15
node_modules/config/raw.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* This is meant to wrap configuration objects that should be left as is,
|
||||||
|
* meaning that the object or its prototype will not be modified in any way
|
||||||
|
*/
|
||||||
|
function RawConfig () {
|
||||||
|
}
|
||||||
|
|
||||||
|
function raw(rawObj) {
|
||||||
|
var obj = Object.create(RawConfig.prototype);
|
||||||
|
obj.resolve = function () { return rawObj; }
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.RawConfig = RawConfig;
|
||||||
|
module.exports.raw = raw;
|
23
node_modules/json5/LICENSE.md
generated
vendored
Normal file
23
node_modules/json5/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2012-2018 Aseem Kishore, and [others].
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
[others]: https://github.com/json5/json5/contributors
|
282
node_modules/json5/README.md
generated
vendored
Normal file
282
node_modules/json5/README.md
generated
vendored
Normal file
|
@ -0,0 +1,282 @@
|
||||||
|
# JSON5 – JSON for Humans
|
||||||
|
|
||||||
|
[![Build Status](https://app.travis-ci.com/json5/json5.svg?branch=main)][Build
|
||||||
|
Status] [![Coverage
|
||||||
|
Status](https://coveralls.io/repos/github/json5/json5/badge.svg)][Coverage
|
||||||
|
Status]
|
||||||
|
|
||||||
|
JSON5 is an extension to the popular [JSON] file format that aims to be
|
||||||
|
easier to **write and maintain _by hand_ (e.g. for config files)**.
|
||||||
|
It is _not intended_ to be used for machine-to-machine communication.
|
||||||
|
(Keep using JSON or other file formats for that. 🙂)
|
||||||
|
|
||||||
|
JSON5 was started in 2012, and as of 2022, now gets **[>65M downloads/week](https://www.npmjs.com/package/json5)**,
|
||||||
|
ranks in the **[top 0.1%](https://gist.github.com/anvaka/8e8fa57c7ee1350e3491)** of the most depended-upon packages on npm,
|
||||||
|
and has been adopted by major projects like
|
||||||
|
**[Chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5;drc=5de823b36e68fd99009a29281b17bc3a1d6b329c),
|
||||||
|
[Next.js](https://github.com/vercel/next.js/blob/b88f20c90bf4659b8ad5cb2a27956005eac2c7e8/packages/next/lib/find-config.ts#L43-L46),
|
||||||
|
[Babel](https://babeljs.io/docs/en/config-files#supported-file-extensions),
|
||||||
|
[Retool](https://community.retool.com/t/i-am-attempting-to-append-several-text-fields-to-a-google-sheet-but-receiving-a-json5-invalid-character-error/7626),
|
||||||
|
[WebStorm](https://www.jetbrains.com/help/webstorm/json.html),
|
||||||
|
and [more](https://github.com/json5/json5/wiki/In-the-Wild)**.
|
||||||
|
It's also natively supported on **[Apple platforms](https://developer.apple.com/documentation/foundation/jsondecoder/3766916-allowsjson5)**
|
||||||
|
like **MacOS** and **iOS**.
|
||||||
|
|
||||||
|
Formally, the **[JSON5 Data Interchange Format](https://spec.json5.org/)** is a superset of JSON
|
||||||
|
(so valid JSON files will always be valid JSON5 files)
|
||||||
|
that expands its syntax to include some productions from [ECMAScript 5.1] (ES5).
|
||||||
|
It's also a strict _subset_ of ES5, so valid JSON5 files will always be valid ES5.
|
||||||
|
|
||||||
|
This JavaScript library is a reference implementation for JSON5 parsing and serialization,
|
||||||
|
and is directly used in many of the popular projects mentioned above
|
||||||
|
(where e.g. extreme performance isn't necessary),
|
||||||
|
but others have created [many other libraries](https://github.com/json5/json5/wiki/In-the-Wild)
|
||||||
|
across many other platforms.
|
||||||
|
|
||||||
|
[Build Status]: https://app.travis-ci.com/json5/json5
|
||||||
|
|
||||||
|
[Coverage Status]: https://coveralls.io/github/json5/json5
|
||||||
|
|
||||||
|
[JSON]: https://tools.ietf.org/html/rfc7159
|
||||||
|
|
||||||
|
[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
|
||||||
|
|
||||||
|
## Summary of Features
|
||||||
|
The following ECMAScript 5.1 features, which are not supported in JSON, have
|
||||||
|
been extended to JSON5.
|
||||||
|
|
||||||
|
### Objects
|
||||||
|
- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
|
||||||
|
- Objects may have a single trailing comma.
|
||||||
|
|
||||||
|
### Arrays
|
||||||
|
- Arrays may have a single trailing comma.
|
||||||
|
|
||||||
|
### Strings
|
||||||
|
- Strings may be single quoted.
|
||||||
|
- Strings may span multiple lines by escaping new line characters.
|
||||||
|
- Strings may include character escapes.
|
||||||
|
|
||||||
|
### Numbers
|
||||||
|
- Numbers may be hexadecimal.
|
||||||
|
- Numbers may have a leading or trailing decimal point.
|
||||||
|
- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
|
||||||
|
- Numbers may begin with an explicit plus sign.
|
||||||
|
|
||||||
|
### Comments
|
||||||
|
- Single and multi-line comments are allowed.
|
||||||
|
|
||||||
|
### White Space
|
||||||
|
- Additional white space characters are allowed.
|
||||||
|
|
||||||
|
[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||||
|
|
||||||
|
[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
|
||||||
|
|
||||||
|
## Example
|
||||||
|
Kitchen-sink example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
// comments
|
||||||
|
unquoted: 'and you can quote me on that',
|
||||||
|
singleQuotes: 'I can use "double quotes" here',
|
||||||
|
lineBreaks: "Look, Mom! \
|
||||||
|
No \\n's!",
|
||||||
|
hexadecimal: 0xdecaf,
|
||||||
|
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
||||||
|
positiveSign: +1,
|
||||||
|
trailingComma: 'in objects', andIn: ['arrays',],
|
||||||
|
"backwardsCompatible": "with JSON",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
A more real-world example is [this config file](https://github.com/chromium/chromium/blob/feb3c9f670515edf9a88f185301cbd7794ee3e52/third_party/blink/renderer/platform/runtime_enabled_features.json5)
|
||||||
|
from the Chromium/Blink project.
|
||||||
|
|
||||||
|
## Specification
|
||||||
|
For a detailed explanation of the JSON5 format, please read the [official
|
||||||
|
specification](https://json5.github.io/json5-spec/).
|
||||||
|
|
||||||
|
## Installation and Usage
|
||||||
|
### Node.js
|
||||||
|
```sh
|
||||||
|
npm install json5
|
||||||
|
```
|
||||||
|
|
||||||
|
#### CommonJS
|
||||||
|
```js
|
||||||
|
const JSON5 = require('json5')
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Modules
|
||||||
|
```js
|
||||||
|
import JSON5 from 'json5'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Browsers
|
||||||
|
#### UMD
|
||||||
|
```html
|
||||||
|
<!-- This will create a global `JSON5` variable. -->
|
||||||
|
<script src="https://unpkg.com/json5@2/dist/index.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Modules
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import JSON5 from 'https://unpkg.com/json5@2/dist/index.min.mjs'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
The JSON5 API is compatible with the [JSON API].
|
||||||
|
|
||||||
|
[JSON API]:
|
||||||
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
|
||||||
|
|
||||||
|
### JSON5.parse()
|
||||||
|
Parses a JSON5 string, constructing the JavaScript value or object described by
|
||||||
|
the string. An optional reviver function can be provided to perform a
|
||||||
|
transformation on the resulting object before it is returned.
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
JSON5.parse(text[, reviver])
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
- `text`: The string to parse as JSON5.
|
||||||
|
- `reviver`: If a function, this prescribes how the value originally produced by
|
||||||
|
parsing is transformed, before being returned.
|
||||||
|
|
||||||
|
#### Return value
|
||||||
|
The object corresponding to the given JSON5 text.
|
||||||
|
|
||||||
|
### JSON5.stringify()
|
||||||
|
Converts a JavaScript value to a JSON5 string, optionally replacing values if a
|
||||||
|
replacer function is specified, or optionally including only the specified
|
||||||
|
properties if a replacer array is specified.
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
JSON5.stringify(value[, replacer[, space]])
|
||||||
|
JSON5.stringify(value[, options])
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
- `value`: The value to convert to a JSON5 string.
|
||||||
|
- `replacer`: A function that alters the behavior of the stringification
|
||||||
|
process, or an array of String and Number objects that serve as a whitelist
|
||||||
|
for selecting/filtering the properties of the value object to be included in
|
||||||
|
the JSON5 string. If this value is null or not provided, all properties of the
|
||||||
|
object are included in the resulting JSON5 string.
|
||||||
|
- `space`: A String or Number object that's used to insert white space into the
|
||||||
|
output JSON5 string for readability purposes. If this is a Number, it
|
||||||
|
indicates the number of space characters to use as white space; this number is
|
||||||
|
capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||||
|
indicate that no space should be used. If this is a String, the string (or the
|
||||||
|
first 10 characters of the string, if it's longer than that) is used as white
|
||||||
|
space. If this parameter is not provided (or is null), no white space is used.
|
||||||
|
If white space is used, trailing commas will be used in objects and arrays.
|
||||||
|
- `options`: An object with the following properties:
|
||||||
|
- `replacer`: Same as the `replacer` parameter.
|
||||||
|
- `space`: Same as the `space` parameter.
|
||||||
|
- `quote`: A String representing the quote character to use when serializing
|
||||||
|
strings.
|
||||||
|
|
||||||
|
#### Return value
|
||||||
|
A JSON5 string representing the value.
|
||||||
|
|
||||||
|
### Node.js `require()` JSON5 files
|
||||||
|
When using Node.js, you can `require()` JSON5 files by adding the following
|
||||||
|
statement.
|
||||||
|
|
||||||
|
```js
|
||||||
|
require('json5/lib/register')
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can load a JSON5 file with a Node.js `require()` statement. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const config = require('./config.json5')
|
||||||
|
```
|
||||||
|
|
||||||
|
## CLI
|
||||||
|
Since JSON is more widely used than JSON5, this package includes a CLI for
|
||||||
|
converting JSON5 to JSON and for validating the syntax of JSON5 documents.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
```sh
|
||||||
|
npm install --global json5
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
```sh
|
||||||
|
json5 [options] <file>
|
||||||
|
```
|
||||||
|
|
||||||
|
If `<file>` is not provided, then STDIN is used.
|
||||||
|
|
||||||
|
#### Options:
|
||||||
|
- `-s`, `--space`: The number of spaces to indent or `t` for tabs
|
||||||
|
- `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
|
||||||
|
- `-v`, `--validate`: Validate JSON5 but do not output JSON
|
||||||
|
- `-V`, `--version`: Output the version number
|
||||||
|
- `-h`, `--help`: Output usage information
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
### Development
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/json5/json5
|
||||||
|
cd json5
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
When contributing code, please write relevant tests and run `npm test` and `npm
|
||||||
|
run lint` before submitting pull requests. Please use an editor that supports
|
||||||
|
[EditorConfig](http://editorconfig.org/).
|
||||||
|
|
||||||
|
### Issues
|
||||||
|
To report bugs or request features regarding the JSON5 **data format**,
|
||||||
|
please submit an issue to the official
|
||||||
|
**[_specification_ repository](https://github.com/json5/json5-spec)**.
|
||||||
|
|
||||||
|
Note that we will never add any features that make JSON5 incompatible with ES5;
|
||||||
|
that compatibility is a fundamental premise of JSON5.
|
||||||
|
|
||||||
|
To report bugs or request features regarding this **JavaScript implementation**
|
||||||
|
of JSON5, please submit an issue to **_this_ repository**.
|
||||||
|
|
||||||
|
### Security Vulnerabilities and Disclosures
|
||||||
|
To report a security vulnerability, please follow the follow the guidelines
|
||||||
|
described in our [security policy](./SECURITY.md).
|
||||||
|
|
||||||
|
## License
|
||||||
|
MIT. See [LICENSE.md](./LICENSE.md) for details.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
[Aseem Kishore](https://github.com/aseemk) founded this project.
|
||||||
|
He wrote a [blog post](https://aseemk.substack.com/p/ignore-the-f-ing-haters-json5)
|
||||||
|
about the journey and lessons learned 10 years in.
|
||||||
|
|
||||||
|
[Michael Bolin](http://bolinfest.com/) independently arrived at and published
|
||||||
|
some of these same ideas with awesome explanations and detail. Recommended
|
||||||
|
reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
|
||||||
|
|
||||||
|
[Douglas Crockford](http://www.crockford.com/) of course designed and built
|
||||||
|
JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
|
||||||
|
cheesy as it may sound, gave us motivation and confidence that building a new
|
||||||
|
parser to implement these ideas was within reach! The original
|
||||||
|
implementation of JSON5 was also modeled directly off of Doug’s open-source
|
||||||
|
[json_parse.js] parser. We’re grateful for that clean and well-documented
|
||||||
|
code.
|
||||||
|
|
||||||
|
[json_parse.js]:
|
||||||
|
https://github.com/douglascrockford/JSON-js/blob/03157639c7a7cddd2e9f032537f346f1a87c0f6d/json_parse.js
|
||||||
|
|
||||||
|
[Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
|
||||||
|
supporter, contributing multiple patches and ideas.
|
||||||
|
|
||||||
|
[Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
|
||||||
|
`stringify` method.
|
||||||
|
|
||||||
|
[Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
|
||||||
|
with ES5, wrote the official JSON5 specification, completely rewrote the
|
||||||
|
codebase from the ground up, and is actively maintaining this project.
|
1737
node_modules/json5/dist/index.js
generated
vendored
Normal file
1737
node_modules/json5/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/json5/dist/index.min.js
generated
vendored
Normal file
1
node_modules/json5/dist/index.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/json5/dist/index.min.mjs
generated
vendored
Normal file
1
node_modules/json5/dist/index.min.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1426
node_modules/json5/dist/index.mjs
generated
vendored
Normal file
1426
node_modules/json5/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
152
node_modules/json5/lib/cli.js
generated
vendored
Normal file
152
node_modules/json5/lib/cli.js
generated
vendored
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const pkg = require('../package.json')
|
||||||
|
const JSON5 = require('./')
|
||||||
|
|
||||||
|
const argv = parseArgs()
|
||||||
|
|
||||||
|
if (argv.version) {
|
||||||
|
version()
|
||||||
|
} else if (argv.help) {
|
||||||
|
usage()
|
||||||
|
} else {
|
||||||
|
const inFilename = argv.defaults[0]
|
||||||
|
|
||||||
|
let readStream
|
||||||
|
if (inFilename) {
|
||||||
|
readStream = fs.createReadStream(inFilename)
|
||||||
|
} else {
|
||||||
|
readStream = process.stdin
|
||||||
|
}
|
||||||
|
|
||||||
|
let json5 = ''
|
||||||
|
readStream.on('data', data => {
|
||||||
|
json5 += data
|
||||||
|
})
|
||||||
|
|
||||||
|
readStream.on('end', () => {
|
||||||
|
let space
|
||||||
|
if (argv.space === 't' || argv.space === 'tab') {
|
||||||
|
space = '\t'
|
||||||
|
} else {
|
||||||
|
space = Number(argv.space)
|
||||||
|
}
|
||||||
|
|
||||||
|
let value
|
||||||
|
try {
|
||||||
|
value = JSON5.parse(json5)
|
||||||
|
if (!argv.validate) {
|
||||||
|
const json = JSON.stringify(value, null, space)
|
||||||
|
|
||||||
|
let writeStream
|
||||||
|
|
||||||
|
// --convert is for backward compatibility with v0.5.1. If
|
||||||
|
// specified with <file> and not --out-file, then a file with
|
||||||
|
// the same name but with a .json extension will be written.
|
||||||
|
if (argv.convert && inFilename && !argv.outFile) {
|
||||||
|
const parsedFilename = path.parse(inFilename)
|
||||||
|
const outFilename = path.format(
|
||||||
|
Object.assign(
|
||||||
|
parsedFilename,
|
||||||
|
{base: path.basename(parsedFilename.base, parsedFilename.ext) + '.json'}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
writeStream = fs.createWriteStream(outFilename)
|
||||||
|
} else if (argv.outFile) {
|
||||||
|
writeStream = fs.createWriteStream(argv.outFile)
|
||||||
|
} else {
|
||||||
|
writeStream = process.stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
writeStream.write(json)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseArgs () {
|
||||||
|
let convert
|
||||||
|
let space
|
||||||
|
let validate
|
||||||
|
let outFile
|
||||||
|
let version
|
||||||
|
let help
|
||||||
|
const defaults = []
|
||||||
|
|
||||||
|
const args = process.argv.slice(2)
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
const arg = args[i]
|
||||||
|
switch (arg) {
|
||||||
|
case '--convert':
|
||||||
|
case '-c':
|
||||||
|
convert = true
|
||||||
|
break
|
||||||
|
|
||||||
|
case '--space':
|
||||||
|
case '-s':
|
||||||
|
space = args[++i]
|
||||||
|
break
|
||||||
|
|
||||||
|
case '--validate':
|
||||||
|
case '-v':
|
||||||
|
validate = true
|
||||||
|
break
|
||||||
|
|
||||||
|
case '--out-file':
|
||||||
|
case '-o':
|
||||||
|
outFile = args[++i]
|
||||||
|
break
|
||||||
|
|
||||||
|
case '--version':
|
||||||
|
case '-V':
|
||||||
|
version = true
|
||||||
|
break
|
||||||
|
|
||||||
|
case '--help':
|
||||||
|
case '-h':
|
||||||
|
help = true
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
defaults.push(arg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
convert,
|
||||||
|
space,
|
||||||
|
validate,
|
||||||
|
outFile,
|
||||||
|
version,
|
||||||
|
help,
|
||||||
|
defaults,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function version () {
|
||||||
|
console.log(pkg.version)
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage () {
|
||||||
|
console.log(
|
||||||
|
`
|
||||||
|
Usage: json5 [options] <file>
|
||||||
|
|
||||||
|
If <file> is not provided, then STDIN is used.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-s, --space The number of spaces to indent or 't' for tabs
|
||||||
|
-o, --out-file [file] Output to the specified file, otherwise STDOUT
|
||||||
|
-v, --validate Validate JSON5 but do not output JSON
|
||||||
|
-V, --version Output the version number
|
||||||
|
-h, --help Output usage information`
|
||||||
|
)
|
||||||
|
}
|
4
node_modules/json5/lib/index.d.ts
generated
vendored
Normal file
4
node_modules/json5/lib/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import parse = require('./parse')
|
||||||
|
import stringify = require('./stringify')
|
||||||
|
|
||||||
|
export {parse, stringify}
|
9
node_modules/json5/lib/index.js
generated
vendored
Normal file
9
node_modules/json5/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const parse = require('./parse')
|
||||||
|
const stringify = require('./stringify')
|
||||||
|
|
||||||
|
const JSON5 = {
|
||||||
|
parse,
|
||||||
|
stringify,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = JSON5
|
15
node_modules/json5/lib/parse.d.ts
generated
vendored
Normal file
15
node_modules/json5/lib/parse.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* Parses a JSON5 string, constructing the JavaScript value or object described
|
||||||
|
* by the string.
|
||||||
|
* @template T The type of the return value.
|
||||||
|
* @param text The string to parse as JSON5.
|
||||||
|
* @param reviver A function that prescribes how the value originally produced
|
||||||
|
* by parsing is transformed before being returned.
|
||||||
|
* @returns The JavaScript value converted from the JSON5 string.
|
||||||
|
*/
|
||||||
|
declare function parse<T = any>(
|
||||||
|
text: string,
|
||||||
|
reviver?: ((this: any, key: string, value: any) => any) | null,
|
||||||
|
): T
|
||||||
|
|
||||||
|
export = parse
|
1114
node_modules/json5/lib/parse.js
generated
vendored
Normal file
1114
node_modules/json5/lib/parse.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
node_modules/json5/lib/register.js
generated
vendored
Normal file
13
node_modules/json5/lib/register.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
const fs = require('fs')
|
||||||
|
const JSON5 = require('./')
|
||||||
|
|
||||||
|
// eslint-disable-next-line node/no-deprecated-api
|
||||||
|
require.extensions['.json5'] = function (module, filename) {
|
||||||
|
const content = fs.readFileSync(filename, 'utf8')
|
||||||
|
try {
|
||||||
|
module.exports = JSON5.parse(content)
|
||||||
|
} catch (err) {
|
||||||
|
err.message = filename + ': ' + err.message
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
4
node_modules/json5/lib/require.js
generated
vendored
Normal file
4
node_modules/json5/lib/require.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// This file is for backward compatibility with v0.5.1.
|
||||||
|
require('./register')
|
||||||
|
|
||||||
|
console.warn("'json5/require' is deprecated. Please use 'json5/register' instead.")
|
89
node_modules/json5/lib/stringify.d.ts
generated
vendored
Normal file
89
node_modules/json5/lib/stringify.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
declare type StringifyOptions = {
|
||||||
|
/**
|
||||||
|
* A function that alters the behavior of the stringification process, or an
|
||||||
|
* array of String and Number objects that serve as a allowlist for
|
||||||
|
* selecting/filtering the properties of the value object to be included in
|
||||||
|
* the JSON5 string. If this value is null or not provided, all properties
|
||||||
|
* of the object are included in the resulting JSON5 string.
|
||||||
|
*/
|
||||||
|
replacer?:
|
||||||
|
| ((this: any, key: string, value: any) => any)
|
||||||
|
| (string | number)[]
|
||||||
|
| null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A String or Number object that's used to insert white space into the
|
||||||
|
* output JSON5 string for readability purposes. If this is a Number, it
|
||||||
|
* indicates the number of space characters to use as white space; this
|
||||||
|
* number is capped at 10 (if it is greater, the value is just 10). Values
|
||||||
|
* less than 1 indicate that no space should be used. If this is a String,
|
||||||
|
* the string (or the first 10 characters of the string, if it's longer than
|
||||||
|
* that) is used as white space. If this parameter is not provided (or is
|
||||||
|
* null), no white space is used. If white space is used, trailing commas
|
||||||
|
* will be used in objects and arrays.
|
||||||
|
*/
|
||||||
|
space?: string | number | null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A String representing the quote character to use when serializing
|
||||||
|
* strings.
|
||||||
|
*/
|
||||||
|
quote?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a JavaScript value to a JSON5 string.
|
||||||
|
* @param value The value to convert to a JSON5 string.
|
||||||
|
* @param replacer A function that alters the behavior of the stringification
|
||||||
|
* process. If this value is null or not provided, all properties of the object
|
||||||
|
* are included in the resulting JSON5 string.
|
||||||
|
* @param space A String or Number object that's used to insert white space into
|
||||||
|
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||||
|
* indicates the number of space characters to use as white space; this number
|
||||||
|
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||||
|
* indicate that no space should be used. If this is a String, the string (or
|
||||||
|
* the first 10 characters of the string, if it's longer than that) is used as
|
||||||
|
* white space. If this parameter is not provided (or is null), no white space
|
||||||
|
* is used. If white space is used, trailing commas will be used in objects and
|
||||||
|
* arrays.
|
||||||
|
* @returns The JSON5 string converted from the JavaScript value.
|
||||||
|
*/
|
||||||
|
declare function stringify(
|
||||||
|
value: any,
|
||||||
|
replacer?: ((this: any, key: string, value: any) => any) | null,
|
||||||
|
space?: string | number | null,
|
||||||
|
): string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a JavaScript value to a JSON5 string.
|
||||||
|
* @param value The value to convert to a JSON5 string.
|
||||||
|
* @param replacer An array of String and Number objects that serve as a
|
||||||
|
* allowlist for selecting/filtering the properties of the value object to be
|
||||||
|
* included in the JSON5 string. If this value is null or not provided, all
|
||||||
|
* properties of the object are included in the resulting JSON5 string.
|
||||||
|
* @param space A String or Number object that's used to insert white space into
|
||||||
|
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||||
|
* indicates the number of space characters to use as white space; this number
|
||||||
|
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||||
|
* indicate that no space should be used. If this is a String, the string (or
|
||||||
|
* the first 10 characters of the string, if it's longer than that) is used as
|
||||||
|
* white space. If this parameter is not provided (or is null), no white space
|
||||||
|
* is used. If white space is used, trailing commas will be used in objects and
|
||||||
|
* arrays.
|
||||||
|
* @returns The JSON5 string converted from the JavaScript value.
|
||||||
|
*/
|
||||||
|
declare function stringify(
|
||||||
|
value: any,
|
||||||
|
replacer: (string | number)[],
|
||||||
|
space?: string | number | null,
|
||||||
|
): string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a JavaScript value to a JSON5 string.
|
||||||
|
* @param value The value to convert to a JSON5 string.
|
||||||
|
* @param options An object specifying options.
|
||||||
|
* @returns The JSON5 string converted from the JavaScript value.
|
||||||
|
*/
|
||||||
|
declare function stringify(value: any, options: StringifyOptions): string
|
||||||
|
|
||||||
|
export = stringify
|
261
node_modules/json5/lib/stringify.js
generated
vendored
Normal file
261
node_modules/json5/lib/stringify.js
generated
vendored
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
const util = require('./util')
|
||||||
|
|
||||||
|
module.exports = function stringify (value, replacer, space) {
|
||||||
|
const stack = []
|
||||||
|
let indent = ''
|
||||||
|
let propertyList
|
||||||
|
let replacerFunc
|
||||||
|
let gap = ''
|
||||||
|
let quote
|
||||||
|
|
||||||
|
if (
|
||||||
|
replacer != null &&
|
||||||
|
typeof replacer === 'object' &&
|
||||||
|
!Array.isArray(replacer)
|
||||||
|
) {
|
||||||
|
space = replacer.space
|
||||||
|
quote = replacer.quote
|
||||||
|
replacer = replacer.replacer
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof replacer === 'function') {
|
||||||
|
replacerFunc = replacer
|
||||||
|
} else if (Array.isArray(replacer)) {
|
||||||
|
propertyList = []
|
||||||
|
for (const v of replacer) {
|
||||||
|
let item
|
||||||
|
|
||||||
|
if (typeof v === 'string') {
|
||||||
|
item = v
|
||||||
|
} else if (
|
||||||
|
typeof v === 'number' ||
|
||||||
|
v instanceof String ||
|
||||||
|
v instanceof Number
|
||||||
|
) {
|
||||||
|
item = String(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item !== undefined && propertyList.indexOf(item) < 0) {
|
||||||
|
propertyList.push(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (space instanceof Number) {
|
||||||
|
space = Number(space)
|
||||||
|
} else if (space instanceof String) {
|
||||||
|
space = String(space)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof space === 'number') {
|
||||||
|
if (space > 0) {
|
||||||
|
space = Math.min(10, Math.floor(space))
|
||||||
|
gap = ' '.substr(0, space)
|
||||||
|
}
|
||||||
|
} else if (typeof space === 'string') {
|
||||||
|
gap = space.substr(0, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
return serializeProperty('', {'': value})
|
||||||
|
|
||||||
|
function serializeProperty (key, holder) {
|
||||||
|
let value = holder[key]
|
||||||
|
if (value != null) {
|
||||||
|
if (typeof value.toJSON5 === 'function') {
|
||||||
|
value = value.toJSON5(key)
|
||||||
|
} else if (typeof value.toJSON === 'function') {
|
||||||
|
value = value.toJSON(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (replacerFunc) {
|
||||||
|
value = replacerFunc.call(holder, key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof Number) {
|
||||||
|
value = Number(value)
|
||||||
|
} else if (value instanceof String) {
|
||||||
|
value = String(value)
|
||||||
|
} else if (value instanceof Boolean) {
|
||||||
|
value = value.valueOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (value) {
|
||||||
|
case null: return 'null'
|
||||||
|
case true: return 'true'
|
||||||
|
case false: return 'false'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
return quoteString(value, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'number') {
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function quoteString (value) {
|
||||||
|
const quotes = {
|
||||||
|
"'": 0.1,
|
||||||
|
'"': 0.2,
|
||||||
|
}
|
||||||
|
|
||||||
|
const replacements = {
|
||||||
|
"'": "\\'",
|
||||||
|
'"': '\\"',
|
||||||
|
'\\': '\\\\',
|
||||||
|
'\b': '\\b',
|
||||||
|
'\f': '\\f',
|
||||||
|
'\n': '\\n',
|
||||||
|
'\r': '\\r',
|
||||||
|
'\t': '\\t',
|
||||||
|
'\v': '\\v',
|
||||||
|
'\0': '\\0',
|
||||||
|
'\u2028': '\\u2028',
|
||||||
|
'\u2029': '\\u2029',
|
||||||
|
}
|
||||||
|
|
||||||
|
let product = ''
|
||||||
|
|
||||||
|
for (let i = 0; i < value.length; i++) {
|
||||||
|
const c = value[i]
|
||||||
|
switch (c) {
|
||||||
|
case "'":
|
||||||
|
case '"':
|
||||||
|
quotes[c]++
|
||||||
|
product += c
|
||||||
|
continue
|
||||||
|
|
||||||
|
case '\0':
|
||||||
|
if (util.isDigit(value[i + 1])) {
|
||||||
|
product += '\\x00'
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (replacements[c]) {
|
||||||
|
product += replacements[c]
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c < ' ') {
|
||||||
|
let hexString = c.charCodeAt(0).toString(16)
|
||||||
|
product += '\\x' + ('00' + hexString).substring(hexString.length)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
product += c
|
||||||
|
}
|
||||||
|
|
||||||
|
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => (quotes[a] < quotes[b]) ? a : b)
|
||||||
|
|
||||||
|
product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar])
|
||||||
|
|
||||||
|
return quoteChar + product + quoteChar
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeObject (value) {
|
||||||
|
if (stack.indexOf(value) >= 0) {
|
||||||
|
throw TypeError('Converting circular structure to JSON5')
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.push(value)
|
||||||
|
|
||||||
|
let stepback = indent
|
||||||
|
indent = indent + gap
|
||||||
|
|
||||||
|
let keys = propertyList || Object.keys(value)
|
||||||
|
let partial = []
|
||||||
|
for (const key of keys) {
|
||||||
|
const propertyString = serializeProperty(key, value)
|
||||||
|
if (propertyString !== undefined) {
|
||||||
|
let member = serializeKey(key) + ':'
|
||||||
|
if (gap !== '') {
|
||||||
|
member += ' '
|
||||||
|
}
|
||||||
|
member += propertyString
|
||||||
|
partial.push(member)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let final
|
||||||
|
if (partial.length === 0) {
|
||||||
|
final = '{}'
|
||||||
|
} else {
|
||||||
|
let properties
|
||||||
|
if (gap === '') {
|
||||||
|
properties = partial.join(',')
|
||||||
|
final = '{' + properties + '}'
|
||||||
|
} else {
|
||||||
|
let separator = ',\n' + indent
|
||||||
|
properties = partial.join(separator)
|
||||||
|
final = '{\n' + indent + properties + ',\n' + stepback + '}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.pop()
|
||||||
|
indent = stepback
|
||||||
|
return final
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeKey (key) {
|
||||||
|
if (key.length === 0) {
|
||||||
|
return quoteString(key, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstChar = String.fromCodePoint(key.codePointAt(0))
|
||||||
|
if (!util.isIdStartChar(firstChar)) {
|
||||||
|
return quoteString(key, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = firstChar.length; i < key.length; i++) {
|
||||||
|
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
||||||
|
return quoteString(key, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeArray (value) {
|
||||||
|
if (stack.indexOf(value) >= 0) {
|
||||||
|
throw TypeError('Converting circular structure to JSON5')
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.push(value)
|
||||||
|
|
||||||
|
let stepback = indent
|
||||||
|
indent = indent + gap
|
||||||
|
|
||||||
|
let partial = []
|
||||||
|
for (let i = 0; i < value.length; i++) {
|
||||||
|
const propertyString = serializeProperty(String(i), value)
|
||||||
|
partial.push((propertyString !== undefined) ? propertyString : 'null')
|
||||||
|
}
|
||||||
|
|
||||||
|
let final
|
||||||
|
if (partial.length === 0) {
|
||||||
|
final = '[]'
|
||||||
|
} else {
|
||||||
|
if (gap === '') {
|
||||||
|
let properties = partial.join(',')
|
||||||
|
final = '[' + properties + ']'
|
||||||
|
} else {
|
||||||
|
let separator = ',\n' + indent
|
||||||
|
let properties = partial.join(separator)
|
||||||
|
final = '[\n' + indent + properties + ',\n' + stepback + ']'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.pop()
|
||||||
|
indent = stepback
|
||||||
|
return final
|
||||||
|
}
|
||||||
|
}
|
3
node_modules/json5/lib/unicode.d.ts
generated
vendored
Normal file
3
node_modules/json5/lib/unicode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export declare const Space_Separator: RegExp
|
||||||
|
export declare const ID_Start: RegExp
|
||||||
|
export declare const ID_Continue: RegExp
|
4
node_modules/json5/lib/unicode.js
generated
vendored
Normal file
4
node_modules/json5/lib/unicode.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/json5/lib/util.d.ts
generated
vendored
Normal file
5
node_modules/json5/lib/util.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export declare function isSpaceSeparator(c?: string): boolean
|
||||||
|
export declare function isIdStartChar(c?: string): boolean
|
||||||
|
export declare function isIdContinueChar(c?: string): boolean
|
||||||
|
export declare function isDigit(c?: string): boolean
|
||||||
|
export declare function isHexDigit(c?: string): boolean
|
35
node_modules/json5/lib/util.js
generated
vendored
Normal file
35
node_modules/json5/lib/util.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const unicode = require('../lib/unicode')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
isSpaceSeparator (c) {
|
||||||
|
return typeof c === 'string' && unicode.Space_Separator.test(c)
|
||||||
|
},
|
||||||
|
|
||||||
|
isIdStartChar (c) {
|
||||||
|
return typeof c === 'string' && (
|
||||||
|
(c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
|
(c === '$') || (c === '_') ||
|
||||||
|
unicode.ID_Start.test(c)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
isIdContinueChar (c) {
|
||||||
|
return typeof c === 'string' && (
|
||||||
|
(c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
|
(c >= '0' && c <= '9') ||
|
||||||
|
(c === '$') || (c === '_') ||
|
||||||
|
(c === '\u200C') || (c === '\u200D') ||
|
||||||
|
unicode.ID_Continue.test(c)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
isDigit (c) {
|
||||||
|
return typeof c === 'string' && /[0-9]/.test(c)
|
||||||
|
},
|
||||||
|
|
||||||
|
isHexDigit (c) {
|
||||||
|
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
|
||||||
|
},
|
||||||
|
}
|
72
node_modules/json5/package.json
generated
vendored
Normal file
72
node_modules/json5/package.json
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
"name": "json5",
|
||||||
|
"version": "2.2.3",
|
||||||
|
"description": "JSON for Humans",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"module": "dist/index.mjs",
|
||||||
|
"bin": "lib/cli.js",
|
||||||
|
"browser": "dist/index.js",
|
||||||
|
"types": "lib/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"lib/",
|
||||||
|
"dist/"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "rollup -c",
|
||||||
|
"build-package": "node build/package.js",
|
||||||
|
"build-unicode": "node build/unicode.js",
|
||||||
|
"coverage": "tap --coverage-report html test",
|
||||||
|
"lint": "eslint --fix .",
|
||||||
|
"lint-report": "eslint .",
|
||||||
|
"prepublishOnly": "npm run production",
|
||||||
|
"preversion": "npm run production",
|
||||||
|
"production": "run-s test build",
|
||||||
|
"tap": "tap -Rspec --100 test",
|
||||||
|
"test": "run-s lint-report tap",
|
||||||
|
"version": "npm run build-package && git add package.json5"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/json5/json5.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"json",
|
||||||
|
"json5",
|
||||||
|
"es5",
|
||||||
|
"es2015",
|
||||||
|
"ecmascript"
|
||||||
|
],
|
||||||
|
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
|
||||||
|
"contributors": [
|
||||||
|
"Max Nanasy <max.nanasy@gmail.com>",
|
||||||
|
"Andrew Eisenberg <andrew@eisenberg.as>",
|
||||||
|
"Jordan Tucker <jordanbtucker@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/json5/json5/issues"
|
||||||
|
},
|
||||||
|
"homepage": "http://json5.org/",
|
||||||
|
"devDependencies": {
|
||||||
|
"core-js": "^2.6.5",
|
||||||
|
"eslint": "^5.15.3",
|
||||||
|
"eslint-config-standard": "^12.0.0",
|
||||||
|
"eslint-plugin-import": "^2.16.0",
|
||||||
|
"eslint-plugin-node": "^8.0.1",
|
||||||
|
"eslint-plugin-promise": "^4.0.1",
|
||||||
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"regenerate": "^1.4.0",
|
||||||
|
"rollup": "^0.64.1",
|
||||||
|
"rollup-plugin-buble": "^0.19.6",
|
||||||
|
"rollup-plugin-commonjs": "^9.2.1",
|
||||||
|
"rollup-plugin-node-resolve": "^3.4.0",
|
||||||
|
"rollup-plugin-terser": "^1.0.1",
|
||||||
|
"sinon": "^6.3.5",
|
||||||
|
"tap": "^12.6.0",
|
||||||
|
"unicode-10.0.0": "^0.7.5"
|
||||||
|
}
|
||||||
|
}
|
4
node_modules/mgrs/.npmignore
generated
vendored
Normal file
4
node_modules/mgrs/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
*~
|
||||||
|
node_modules
|
||||||
|
.DS_STORE
|
||||||
|
coverage
|
17
node_modules/mgrs/PUBLISHING.md
generated
vendored
Normal file
17
node_modules/mgrs/PUBLISHING.md
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Publishing
|
||||||
|
===
|
||||||
|
|
||||||
|
Use `tin` to update the version number in `package.json`.
|
||||||
|
|
||||||
|
tin -v x.y.z
|
||||||
|
|
||||||
|
Then run the publish script
|
||||||
|
|
||||||
|
./publish.sh
|
||||||
|
|
||||||
|
afterwards don't forget to update the versions to be a prerelease of the next version, so if you just published 1.1.1 then:
|
||||||
|
|
||||||
|
tin -v 1.1.2-alpha
|
||||||
|
git add package.json
|
||||||
|
git commit -m 'update version to 1.1.2-alpha'
|
||||||
|
git push origin master
|
758
node_modules/mgrs/dist/mgrs.js
generated
vendored
Normal file
758
node_modules/mgrs/dist/mgrs.js
generated
vendored
Normal file
|
@ -0,0 +1,758 @@
|
||||||
|
(function (global, factory) {
|
||||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||||
|
(factory((global.mgrs = global.mgrs || {})));
|
||||||
|
}(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UTM zones are grouped, and assigned to one of a group of 6
|
||||||
|
* sets.
|
||||||
|
*
|
||||||
|
* {int} @private
|
||||||
|
*/
|
||||||
|
var NUM_100K_SETS = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column letters (for easting) of the lower left value, per
|
||||||
|
* set.
|
||||||
|
*
|
||||||
|
* {string} @private
|
||||||
|
*/
|
||||||
|
var SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The row letters (for northing) of the lower left value, per
|
||||||
|
* set.
|
||||||
|
*
|
||||||
|
* {string} @private
|
||||||
|
*/
|
||||||
|
var SET_ORIGIN_ROW_LETTERS = 'AFAFAF';
|
||||||
|
|
||||||
|
var A = 65; // A
|
||||||
|
var I = 73; // I
|
||||||
|
var O = 79; // O
|
||||||
|
var V = 86; // V
|
||||||
|
var Z = 90; // Z
|
||||||
|
var mgrs = {
|
||||||
|
forward: forward,
|
||||||
|
inverse: inverse,
|
||||||
|
toPoint: toPoint
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Conversion of lat/lon to MGRS.
|
||||||
|
*
|
||||||
|
* @param {object} ll Object literal with lat and lon properties on a
|
||||||
|
* WGS84 ellipsoid.
|
||||||
|
* @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for
|
||||||
|
* 100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.
|
||||||
|
* @return {string} the MGRS string for the given location and accuracy.
|
||||||
|
*/
|
||||||
|
function forward(ll, accuracy) {
|
||||||
|
accuracy = accuracy || 5; // default accuracy 1m
|
||||||
|
return encode(LLtoUTM({
|
||||||
|
lat: ll[1],
|
||||||
|
lon: ll[0]
|
||||||
|
}), accuracy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion of MGRS to lat/lon.
|
||||||
|
*
|
||||||
|
* @param {string} mgrs MGRS string.
|
||||||
|
* @return {array} An array with left (longitude), bottom (latitude), right
|
||||||
|
* (longitude) and top (latitude) values in WGS84, representing the
|
||||||
|
* bounding box for the provided MGRS reference.
|
||||||
|
*/
|
||||||
|
function inverse(mgrs) {
|
||||||
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
||||||
|
if (bbox.lat && bbox.lon) {
|
||||||
|
return [bbox.lon, bbox.lat, bbox.lon, bbox.lat];
|
||||||
|
}
|
||||||
|
return [bbox.left, bbox.bottom, bbox.right, bbox.top];
|
||||||
|
}
|
||||||
|
|
||||||
|
function toPoint(mgrs) {
|
||||||
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
||||||
|
if (bbox.lat && bbox.lon) {
|
||||||
|
return [bbox.lon, bbox.lat];
|
||||||
|
}
|
||||||
|
return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Conversion from degrees to radians.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} deg the angle in degrees.
|
||||||
|
* @return {number} the angle in radians.
|
||||||
|
*/
|
||||||
|
function degToRad(deg) {
|
||||||
|
return (deg * (Math.PI / 180.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion from radians to degrees.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} rad the angle in radians.
|
||||||
|
* @return {number} the angle in degrees.
|
||||||
|
*/
|
||||||
|
function radToDeg(rad) {
|
||||||
|
return (180.0 * (rad / Math.PI));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a set of Longitude and Latitude co-ordinates to UTM
|
||||||
|
* using the WGS84 ellipsoid.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} ll Object literal with lat and lon properties
|
||||||
|
* representing the WGS84 coordinate to be converted.
|
||||||
|
* @return {object} Object literal containing the UTM value with easting,
|
||||||
|
* northing, zoneNumber and zoneLetter properties, and an optional
|
||||||
|
* accuracy property in digits. Returns null if the conversion failed.
|
||||||
|
*/
|
||||||
|
function LLtoUTM(ll) {
|
||||||
|
var Lat = ll.lat;
|
||||||
|
var Long = ll.lon;
|
||||||
|
var a = 6378137.0; //ellip.radius;
|
||||||
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
||||||
|
var k0 = 0.9996;
|
||||||
|
var LongOrigin;
|
||||||
|
var eccPrimeSquared;
|
||||||
|
var N, T, C, A, M;
|
||||||
|
var LatRad = degToRad(Lat);
|
||||||
|
var LongRad = degToRad(Long);
|
||||||
|
var LongOriginRad;
|
||||||
|
var ZoneNumber;
|
||||||
|
// (int)
|
||||||
|
ZoneNumber = Math.floor((Long + 180) / 6) + 1;
|
||||||
|
|
||||||
|
//Make sure the longitude 180.00 is in Zone 60
|
||||||
|
if (Long === 180) {
|
||||||
|
ZoneNumber = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special zone for Norway
|
||||||
|
if (Lat >= 56.0 && Lat < 64.0 && Long >= 3.0 && Long < 12.0) {
|
||||||
|
ZoneNumber = 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special zones for Svalbard
|
||||||
|
if (Lat >= 72.0 && Lat < 84.0) {
|
||||||
|
if (Long >= 0.0 && Long < 9.0) {
|
||||||
|
ZoneNumber = 31;
|
||||||
|
}
|
||||||
|
else if (Long >= 9.0 && Long < 21.0) {
|
||||||
|
ZoneNumber = 33;
|
||||||
|
}
|
||||||
|
else if (Long >= 21.0 && Long < 33.0) {
|
||||||
|
ZoneNumber = 35;
|
||||||
|
}
|
||||||
|
else if (Long >= 33.0 && Long < 42.0) {
|
||||||
|
ZoneNumber = 37;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts origin
|
||||||
|
// in middle of
|
||||||
|
// zone
|
||||||
|
LongOriginRad = degToRad(LongOrigin);
|
||||||
|
|
||||||
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
||||||
|
|
||||||
|
N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));
|
||||||
|
T = Math.tan(LatRad) * Math.tan(LatRad);
|
||||||
|
C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
|
||||||
|
A = Math.cos(LatRad) * (LongRad - LongOriginRad);
|
||||||
|
|
||||||
|
M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - (35 * eccSquared * eccSquared * eccSquared / 3072) * Math.sin(6 * LatRad));
|
||||||
|
|
||||||
|
var UTMEasting = (k0 * N * (A + (1 - T + C) * A * A * A / 6.0 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0);
|
||||||
|
|
||||||
|
var UTMNorthing = (k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24.0 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720.0)));
|
||||||
|
if (Lat < 0.0) {
|
||||||
|
UTMNorthing += 10000000.0; //10000000 meter offset for
|
||||||
|
// southern hemisphere
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
northing: Math.round(UTMNorthing),
|
||||||
|
easting: Math.round(UTMEasting),
|
||||||
|
zoneNumber: ZoneNumber,
|
||||||
|
zoneLetter: getLetterDesignator(Lat)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts UTM coords to lat/long, using the WGS84 ellipsoid. This is a convenience
|
||||||
|
* class where the Zone can be specified as a single string eg."60N" which
|
||||||
|
* is then broken down into the ZoneNumber and ZoneLetter.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} utm An object literal with northing, easting, zoneNumber
|
||||||
|
* and zoneLetter properties. If an optional accuracy property is
|
||||||
|
* provided (in meters), a bounding box will be returned instead of
|
||||||
|
* latitude and longitude.
|
||||||
|
* @return {object} An object literal containing either lat and lon values
|
||||||
|
* (if no accuracy was provided), or top, right, bottom and left values
|
||||||
|
* for the bounding box calculated according to the provided accuracy.
|
||||||
|
* Returns null if the conversion failed.
|
||||||
|
*/
|
||||||
|
function UTMtoLL(utm) {
|
||||||
|
|
||||||
|
var UTMNorthing = utm.northing;
|
||||||
|
var UTMEasting = utm.easting;
|
||||||
|
var zoneLetter = utm.zoneLetter;
|
||||||
|
var zoneNumber = utm.zoneNumber;
|
||||||
|
// check the ZoneNummber is valid
|
||||||
|
if (zoneNumber < 0 || zoneNumber > 60) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var k0 = 0.9996;
|
||||||
|
var a = 6378137.0; //ellip.radius;
|
||||||
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
||||||
|
var eccPrimeSquared;
|
||||||
|
var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));
|
||||||
|
var N1, T1, C1, R1, D, M;
|
||||||
|
var LongOrigin;
|
||||||
|
var mu, phi1Rad;
|
||||||
|
|
||||||
|
// remove 500,000 meter offset for longitude
|
||||||
|
var x = UTMEasting - 500000.0;
|
||||||
|
var y = UTMNorthing;
|
||||||
|
|
||||||
|
// We must know somehow if we are in the Northern or Southern
|
||||||
|
// hemisphere, this is the only time we use the letter So even
|
||||||
|
// if the Zone letter isn't exactly correct it should indicate
|
||||||
|
// the hemisphere correctly
|
||||||
|
if (zoneLetter < 'N') {
|
||||||
|
y -= 10000000.0; // remove 10,000,000 meter offset used
|
||||||
|
// for southern hemisphere
|
||||||
|
}
|
||||||
|
|
||||||
|
// There are 60 zones with zone 1 being at West -180 to -174
|
||||||
|
LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin
|
||||||
|
// in middle of
|
||||||
|
// zone
|
||||||
|
|
||||||
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
||||||
|
|
||||||
|
M = y / k0;
|
||||||
|
mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
|
||||||
|
|
||||||
|
phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.sin(6 * mu);
|
||||||
|
// double phi1 = ProjMath.radToDeg(phi1Rad);
|
||||||
|
|
||||||
|
N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));
|
||||||
|
T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);
|
||||||
|
C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);
|
||||||
|
R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);
|
||||||
|
D = x / (N1 * k0);
|
||||||
|
|
||||||
|
var lat = phi1Rad - (N1 * Math.tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);
|
||||||
|
lat = radToDeg(lat);
|
||||||
|
|
||||||
|
var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);
|
||||||
|
lon = LongOrigin + radToDeg(lon);
|
||||||
|
|
||||||
|
var result;
|
||||||
|
if (utm.accuracy) {
|
||||||
|
var topRight = UTMtoLL({
|
||||||
|
northing: utm.northing + utm.accuracy,
|
||||||
|
easting: utm.easting + utm.accuracy,
|
||||||
|
zoneLetter: utm.zoneLetter,
|
||||||
|
zoneNumber: utm.zoneNumber
|
||||||
|
});
|
||||||
|
result = {
|
||||||
|
top: topRight.lat,
|
||||||
|
right: topRight.lon,
|
||||||
|
bottom: lat,
|
||||||
|
left: lon
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = {
|
||||||
|
lat: lat,
|
||||||
|
lon: lon
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the MGRS letter designator for the given latitude.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} lat The latitude in WGS84 to get the letter designator
|
||||||
|
* for.
|
||||||
|
* @return {char} The letter designator.
|
||||||
|
*/
|
||||||
|
function getLetterDesignator(lat) {
|
||||||
|
//This is here as an error flag to show that the Latitude is
|
||||||
|
//outside MGRS limits
|
||||||
|
var LetterDesignator = 'Z';
|
||||||
|
|
||||||
|
if ((84 >= lat) && (lat >= 72)) {
|
||||||
|
LetterDesignator = 'X';
|
||||||
|
}
|
||||||
|
else if ((72 > lat) && (lat >= 64)) {
|
||||||
|
LetterDesignator = 'W';
|
||||||
|
}
|
||||||
|
else if ((64 > lat) && (lat >= 56)) {
|
||||||
|
LetterDesignator = 'V';
|
||||||
|
}
|
||||||
|
else if ((56 > lat) && (lat >= 48)) {
|
||||||
|
LetterDesignator = 'U';
|
||||||
|
}
|
||||||
|
else if ((48 > lat) && (lat >= 40)) {
|
||||||
|
LetterDesignator = 'T';
|
||||||
|
}
|
||||||
|
else if ((40 > lat) && (lat >= 32)) {
|
||||||
|
LetterDesignator = 'S';
|
||||||
|
}
|
||||||
|
else if ((32 > lat) && (lat >= 24)) {
|
||||||
|
LetterDesignator = 'R';
|
||||||
|
}
|
||||||
|
else if ((24 > lat) && (lat >= 16)) {
|
||||||
|
LetterDesignator = 'Q';
|
||||||
|
}
|
||||||
|
else if ((16 > lat) && (lat >= 8)) {
|
||||||
|
LetterDesignator = 'P';
|
||||||
|
}
|
||||||
|
else if ((8 > lat) && (lat >= 0)) {
|
||||||
|
LetterDesignator = 'N';
|
||||||
|
}
|
||||||
|
else if ((0 > lat) && (lat >= -8)) {
|
||||||
|
LetterDesignator = 'M';
|
||||||
|
}
|
||||||
|
else if ((-8 > lat) && (lat >= -16)) {
|
||||||
|
LetterDesignator = 'L';
|
||||||
|
}
|
||||||
|
else if ((-16 > lat) && (lat >= -24)) {
|
||||||
|
LetterDesignator = 'K';
|
||||||
|
}
|
||||||
|
else if ((-24 > lat) && (lat >= -32)) {
|
||||||
|
LetterDesignator = 'J';
|
||||||
|
}
|
||||||
|
else if ((-32 > lat) && (lat >= -40)) {
|
||||||
|
LetterDesignator = 'H';
|
||||||
|
}
|
||||||
|
else if ((-40 > lat) && (lat >= -48)) {
|
||||||
|
LetterDesignator = 'G';
|
||||||
|
}
|
||||||
|
else if ((-48 > lat) && (lat >= -56)) {
|
||||||
|
LetterDesignator = 'F';
|
||||||
|
}
|
||||||
|
else if ((-56 > lat) && (lat >= -64)) {
|
||||||
|
LetterDesignator = 'E';
|
||||||
|
}
|
||||||
|
else if ((-64 > lat) && (lat >= -72)) {
|
||||||
|
LetterDesignator = 'D';
|
||||||
|
}
|
||||||
|
else if ((-72 > lat) && (lat >= -80)) {
|
||||||
|
LetterDesignator = 'C';
|
||||||
|
}
|
||||||
|
return LetterDesignator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a UTM location as MGRS string.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} utm An object literal with easting, northing,
|
||||||
|
* zoneLetter, zoneNumber
|
||||||
|
* @param {number} accuracy Accuracy in digits (1-5).
|
||||||
|
* @return {string} MGRS string for the given UTM location.
|
||||||
|
*/
|
||||||
|
function encode(utm, accuracy) {
|
||||||
|
// prepend with leading zeroes
|
||||||
|
var seasting = "00000" + utm.easting,
|
||||||
|
snorthing = "00000" + utm.northing;
|
||||||
|
|
||||||
|
return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the two letter 100k designator for a given UTM easting,
|
||||||
|
* northing and zone number value.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} easting
|
||||||
|
* @param {number} northing
|
||||||
|
* @param {number} zoneNumber
|
||||||
|
* @return the two letter 100k designator for the given UTM location.
|
||||||
|
*/
|
||||||
|
function get100kID(easting, northing, zoneNumber) {
|
||||||
|
var setParm = get100kSetForZone(zoneNumber);
|
||||||
|
var setColumn = Math.floor(easting / 100000);
|
||||||
|
var setRow = Math.floor(northing / 100000) % 20;
|
||||||
|
return getLetter100kID(setColumn, setRow, setParm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a UTM zone number, figure out the MGRS 100K set it is in.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} i An UTM zone number.
|
||||||
|
* @return {number} the 100k set the UTM zone is in.
|
||||||
|
*/
|
||||||
|
function get100kSetForZone(i) {
|
||||||
|
var setParm = i % NUM_100K_SETS;
|
||||||
|
if (setParm === 0) {
|
||||||
|
setParm = NUM_100K_SETS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setParm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the two-letter MGRS 100k designator given information
|
||||||
|
* translated from the UTM northing, easting and zone number.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} column the column index as it relates to the MGRS
|
||||||
|
* 100k set spreadsheet, created from the UTM easting.
|
||||||
|
* Values are 1-8.
|
||||||
|
* @param {number} row the row index as it relates to the MGRS 100k set
|
||||||
|
* spreadsheet, created from the UTM northing value. Values
|
||||||
|
* are from 0-19.
|
||||||
|
* @param {number} parm the set block, as it relates to the MGRS 100k set
|
||||||
|
* spreadsheet, created from the UTM zone. Values are from
|
||||||
|
* 1-60.
|
||||||
|
* @return two letter MGRS 100k code.
|
||||||
|
*/
|
||||||
|
function getLetter100kID(column, row, parm) {
|
||||||
|
// colOrigin and rowOrigin are the letters at the origin of the set
|
||||||
|
var index = parm - 1;
|
||||||
|
var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);
|
||||||
|
var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);
|
||||||
|
|
||||||
|
// colInt and rowInt are the letters to build to return
|
||||||
|
var colInt = colOrigin + column - 1;
|
||||||
|
var rowInt = rowOrigin + row;
|
||||||
|
var rollover = false;
|
||||||
|
|
||||||
|
if (colInt > Z) {
|
||||||
|
colInt = colInt - Z + A - 1;
|
||||||
|
rollover = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt === I || (colOrigin < I && colInt > I) || ((colInt > I || colOrigin < I) && rollover)) {
|
||||||
|
colInt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt === O || (colOrigin < O && colInt > O) || ((colInt > O || colOrigin < O) && rollover)) {
|
||||||
|
colInt++;
|
||||||
|
|
||||||
|
if (colInt === I) {
|
||||||
|
colInt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt > Z) {
|
||||||
|
colInt = colInt - Z + A - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowInt > V) {
|
||||||
|
rowInt = rowInt - V + A - 1;
|
||||||
|
rollover = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rollover = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((rowInt === I) || ((rowOrigin < I) && (rowInt > I))) || (((rowInt > I) || (rowOrigin < I)) && rollover)) {
|
||||||
|
rowInt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((rowInt === O) || ((rowOrigin < O) && (rowInt > O))) || (((rowInt > O) || (rowOrigin < O)) && rollover)) {
|
||||||
|
rowInt++;
|
||||||
|
|
||||||
|
if (rowInt === I) {
|
||||||
|
rowInt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowInt > V) {
|
||||||
|
rowInt = rowInt - V + A - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);
|
||||||
|
return twoLetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the UTM parameters from a MGRS string.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {string} mgrsString an UPPERCASE coordinate string is expected.
|
||||||
|
* @return {object} An object literal with easting, northing, zoneLetter,
|
||||||
|
* zoneNumber and accuracy (in meters) properties.
|
||||||
|
*/
|
||||||
|
function decode(mgrsString) {
|
||||||
|
|
||||||
|
if (mgrsString && mgrsString.length === 0) {
|
||||||
|
throw ("MGRSPoint coverting from nothing");
|
||||||
|
}
|
||||||
|
|
||||||
|
var length = mgrsString.length;
|
||||||
|
|
||||||
|
var hunK = null;
|
||||||
|
var sb = "";
|
||||||
|
var testChar;
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
// get Zone number
|
||||||
|
while (!(/[A-Z]/).test(testChar = mgrsString.charAt(i))) {
|
||||||
|
if (i >= 2) {
|
||||||
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
||||||
|
}
|
||||||
|
sb += testChar;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var zoneNumber = parseInt(sb, 10);
|
||||||
|
|
||||||
|
if (i === 0 || i + 3 > length) {
|
||||||
|
// A good MGRS string has to be 4-5 digits long,
|
||||||
|
// ##AAA/#AAA at least.
|
||||||
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
var zoneLetter = mgrsString.charAt(i++);
|
||||||
|
|
||||||
|
// Should we check the zone letter here? Why not.
|
||||||
|
if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {
|
||||||
|
throw ("MGRSPoint zone letter " + zoneLetter + " not handled: " + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
hunK = mgrsString.substring(i, i += 2);
|
||||||
|
|
||||||
|
var set = get100kSetForZone(zoneNumber);
|
||||||
|
|
||||||
|
var east100k = getEastingFromChar(hunK.charAt(0), set);
|
||||||
|
var north100k = getNorthingFromChar(hunK.charAt(1), set);
|
||||||
|
|
||||||
|
// We have a bug where the northing may be 2000000 too low.
|
||||||
|
// How
|
||||||
|
// do we know when to roll over?
|
||||||
|
|
||||||
|
while (north100k < getMinNorthing(zoneLetter)) {
|
||||||
|
north100k += 2000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the char index for easting/northing separator
|
||||||
|
var remainder = length - i;
|
||||||
|
|
||||||
|
if (remainder % 2 !== 0) {
|
||||||
|
throw ("MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters" + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sep = remainder / 2;
|
||||||
|
|
||||||
|
var sepEasting = 0.0;
|
||||||
|
var sepNorthing = 0.0;
|
||||||
|
var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;
|
||||||
|
if (sep > 0) {
|
||||||
|
accuracyBonus = 100000.0 / Math.pow(10, sep);
|
||||||
|
sepEastingString = mgrsString.substring(i, i + sep);
|
||||||
|
sepEasting = parseFloat(sepEastingString) * accuracyBonus;
|
||||||
|
sepNorthingString = mgrsString.substring(i + sep);
|
||||||
|
sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
easting = sepEasting + east100k;
|
||||||
|
northing = sepNorthing + north100k;
|
||||||
|
|
||||||
|
return {
|
||||||
|
easting: easting,
|
||||||
|
northing: northing,
|
||||||
|
zoneLetter: zoneLetter,
|
||||||
|
zoneNumber: zoneNumber,
|
||||||
|
accuracy: accuracyBonus
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the first letter from a two-letter MGRS 100k zone, and given the
|
||||||
|
* MGRS table set for the zone number, figure out the easting value that
|
||||||
|
* should be added to the other, secondary easting value.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} e The first letter from a two-letter MGRS 100´k zone.
|
||||||
|
* @param {number} set The MGRS table set for the zone number.
|
||||||
|
* @return {number} The easting value for the given letter and set.
|
||||||
|
*/
|
||||||
|
function getEastingFromChar(e, set) {
|
||||||
|
// colOrigin is the letter at the origin of the set for the
|
||||||
|
// column
|
||||||
|
var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);
|
||||||
|
var eastingValue = 100000.0;
|
||||||
|
var rewindMarker = false;
|
||||||
|
|
||||||
|
while (curCol !== e.charCodeAt(0)) {
|
||||||
|
curCol++;
|
||||||
|
if (curCol === I) {
|
||||||
|
curCol++;
|
||||||
|
}
|
||||||
|
if (curCol === O) {
|
||||||
|
curCol++;
|
||||||
|
}
|
||||||
|
if (curCol > Z) {
|
||||||
|
if (rewindMarker) {
|
||||||
|
throw ("Bad character: " + e);
|
||||||
|
}
|
||||||
|
curCol = A;
|
||||||
|
rewindMarker = true;
|
||||||
|
}
|
||||||
|
eastingValue += 100000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return eastingValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the second letter from a two-letter MGRS 100k zone, and given the
|
||||||
|
* MGRS table set for the zone number, figure out the northing value that
|
||||||
|
* should be added to the other, secondary northing value. You have to
|
||||||
|
* remember that Northings are determined from the equator, and the vertical
|
||||||
|
* cycle of letters mean a 2000000 additional northing meters. This happens
|
||||||
|
* approx. every 18 degrees of latitude. This method does *NOT* count any
|
||||||
|
* additional northings. You have to figure out how many 2000000 meters need
|
||||||
|
* to be added for the zone letter of the MGRS coordinate.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} n Second letter of the MGRS 100k zone
|
||||||
|
* @param {number} set The MGRS table set number, which is dependent on the
|
||||||
|
* UTM zone number.
|
||||||
|
* @return {number} The northing value for the given letter and set.
|
||||||
|
*/
|
||||||
|
function getNorthingFromChar(n, set) {
|
||||||
|
|
||||||
|
if (n > 'V') {
|
||||||
|
throw ("MGRSPoint given invalid Northing " + n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rowOrigin is the letter at the origin of the set for the
|
||||||
|
// column
|
||||||
|
var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);
|
||||||
|
var northingValue = 0.0;
|
||||||
|
var rewindMarker = false;
|
||||||
|
|
||||||
|
while (curRow !== n.charCodeAt(0)) {
|
||||||
|
curRow++;
|
||||||
|
if (curRow === I) {
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
if (curRow === O) {
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
// fixing a bug making whole application hang in this loop
|
||||||
|
// when 'n' is a wrong character
|
||||||
|
if (curRow > V) {
|
||||||
|
if (rewindMarker) { // making sure that this loop ends
|
||||||
|
throw ("Bad character: " + n);
|
||||||
|
}
|
||||||
|
curRow = A;
|
||||||
|
rewindMarker = true;
|
||||||
|
}
|
||||||
|
northingValue += 100000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return northingValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function getMinNorthing returns the minimum northing value of a MGRS
|
||||||
|
* zone.
|
||||||
|
*
|
||||||
|
* Ported from Geotrans' c Lattitude_Band_Value structure table.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} zoneLetter The MGRS zone to get the min northing for.
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
function getMinNorthing(zoneLetter) {
|
||||||
|
var northing;
|
||||||
|
switch (zoneLetter) {
|
||||||
|
case 'C':
|
||||||
|
northing = 1100000.0;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
northing = 2000000.0;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
northing = 2800000.0;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
northing = 3700000.0;
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
northing = 4600000.0;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
northing = 5500000.0;
|
||||||
|
break;
|
||||||
|
case 'J':
|
||||||
|
northing = 6400000.0;
|
||||||
|
break;
|
||||||
|
case 'K':
|
||||||
|
northing = 7300000.0;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
northing = 8200000.0;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
northing = 9100000.0;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
northing = 0.0;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
northing = 800000.0;
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
northing = 1700000.0;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
northing = 2600000.0;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
northing = 3500000.0;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
northing = 4400000.0;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
northing = 5300000.0;
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
northing = 6200000.0;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
northing = 7000000.0;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
northing = 7900000.0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
northing = -1.0;
|
||||||
|
}
|
||||||
|
if (northing >= 0.0) {
|
||||||
|
return northing;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw ("Invalid zone letter: " + zoneLetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
exports['default'] = mgrs;
|
||||||
|
exports.forward = forward;
|
||||||
|
exports.inverse = inverse;
|
||||||
|
exports.toPoint = toPoint;
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
})));
|
19
node_modules/mgrs/license.md
generated
vendored
Normal file
19
node_modules/mgrs/license.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2012, Mike Adair, Richard Greenwood, Didier Richard, Stephen Irons, Olivier Terral, Calvin Metcalf
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE._
|
746
node_modules/mgrs/mgrs.js
generated
vendored
Normal file
746
node_modules/mgrs/mgrs.js
generated
vendored
Normal file
|
@ -0,0 +1,746 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UTM zones are grouped, and assigned to one of a group of 6
|
||||||
|
* sets.
|
||||||
|
*
|
||||||
|
* {int} @private
|
||||||
|
*/
|
||||||
|
var NUM_100K_SETS = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column letters (for easting) of the lower left value, per
|
||||||
|
* set.
|
||||||
|
*
|
||||||
|
* {string} @private
|
||||||
|
*/
|
||||||
|
var SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The row letters (for northing) of the lower left value, per
|
||||||
|
* set.
|
||||||
|
*
|
||||||
|
* {string} @private
|
||||||
|
*/
|
||||||
|
var SET_ORIGIN_ROW_LETTERS = 'AFAFAF';
|
||||||
|
|
||||||
|
var A = 65; // A
|
||||||
|
var I = 73; // I
|
||||||
|
var O = 79; // O
|
||||||
|
var V = 86; // V
|
||||||
|
var Z = 90; // Z
|
||||||
|
export default {
|
||||||
|
forward: forward,
|
||||||
|
inverse: inverse,
|
||||||
|
toPoint: toPoint
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Conversion of lat/lon to MGRS.
|
||||||
|
*
|
||||||
|
* @param {object} ll Object literal with lat and lon properties on a
|
||||||
|
* WGS84 ellipsoid.
|
||||||
|
* @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for
|
||||||
|
* 100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.
|
||||||
|
* @return {string} the MGRS string for the given location and accuracy.
|
||||||
|
*/
|
||||||
|
export function forward(ll, accuracy) {
|
||||||
|
accuracy = accuracy || 5; // default accuracy 1m
|
||||||
|
return encode(LLtoUTM({
|
||||||
|
lat: ll[1],
|
||||||
|
lon: ll[0]
|
||||||
|
}), accuracy);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion of MGRS to lat/lon.
|
||||||
|
*
|
||||||
|
* @param {string} mgrs MGRS string.
|
||||||
|
* @return {array} An array with left (longitude), bottom (latitude), right
|
||||||
|
* (longitude) and top (latitude) values in WGS84, representing the
|
||||||
|
* bounding box for the provided MGRS reference.
|
||||||
|
*/
|
||||||
|
export function inverse(mgrs) {
|
||||||
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
||||||
|
if (bbox.lat && bbox.lon) {
|
||||||
|
return [bbox.lon, bbox.lat, bbox.lon, bbox.lat];
|
||||||
|
}
|
||||||
|
return [bbox.left, bbox.bottom, bbox.right, bbox.top];
|
||||||
|
};
|
||||||
|
|
||||||
|
export function toPoint(mgrs) {
|
||||||
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
||||||
|
if (bbox.lat && bbox.lon) {
|
||||||
|
return [bbox.lon, bbox.lat];
|
||||||
|
}
|
||||||
|
return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2];
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Conversion from degrees to radians.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} deg the angle in degrees.
|
||||||
|
* @return {number} the angle in radians.
|
||||||
|
*/
|
||||||
|
function degToRad(deg) {
|
||||||
|
return (deg * (Math.PI / 180.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion from radians to degrees.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} rad the angle in radians.
|
||||||
|
* @return {number} the angle in degrees.
|
||||||
|
*/
|
||||||
|
function radToDeg(rad) {
|
||||||
|
return (180.0 * (rad / Math.PI));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a set of Longitude and Latitude co-ordinates to UTM
|
||||||
|
* using the WGS84 ellipsoid.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} ll Object literal with lat and lon properties
|
||||||
|
* representing the WGS84 coordinate to be converted.
|
||||||
|
* @return {object} Object literal containing the UTM value with easting,
|
||||||
|
* northing, zoneNumber and zoneLetter properties, and an optional
|
||||||
|
* accuracy property in digits. Returns null if the conversion failed.
|
||||||
|
*/
|
||||||
|
function LLtoUTM(ll) {
|
||||||
|
var Lat = ll.lat;
|
||||||
|
var Long = ll.lon;
|
||||||
|
var a = 6378137.0; //ellip.radius;
|
||||||
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
||||||
|
var k0 = 0.9996;
|
||||||
|
var LongOrigin;
|
||||||
|
var eccPrimeSquared;
|
||||||
|
var N, T, C, A, M;
|
||||||
|
var LatRad = degToRad(Lat);
|
||||||
|
var LongRad = degToRad(Long);
|
||||||
|
var LongOriginRad;
|
||||||
|
var ZoneNumber;
|
||||||
|
// (int)
|
||||||
|
ZoneNumber = Math.floor((Long + 180) / 6) + 1;
|
||||||
|
|
||||||
|
//Make sure the longitude 180.00 is in Zone 60
|
||||||
|
if (Long === 180) {
|
||||||
|
ZoneNumber = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special zone for Norway
|
||||||
|
if (Lat >= 56.0 && Lat < 64.0 && Long >= 3.0 && Long < 12.0) {
|
||||||
|
ZoneNumber = 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special zones for Svalbard
|
||||||
|
if (Lat >= 72.0 && Lat < 84.0) {
|
||||||
|
if (Long >= 0.0 && Long < 9.0) {
|
||||||
|
ZoneNumber = 31;
|
||||||
|
}
|
||||||
|
else if (Long >= 9.0 && Long < 21.0) {
|
||||||
|
ZoneNumber = 33;
|
||||||
|
}
|
||||||
|
else if (Long >= 21.0 && Long < 33.0) {
|
||||||
|
ZoneNumber = 35;
|
||||||
|
}
|
||||||
|
else if (Long >= 33.0 && Long < 42.0) {
|
||||||
|
ZoneNumber = 37;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts origin
|
||||||
|
// in middle of
|
||||||
|
// zone
|
||||||
|
LongOriginRad = degToRad(LongOrigin);
|
||||||
|
|
||||||
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
||||||
|
|
||||||
|
N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));
|
||||||
|
T = Math.tan(LatRad) * Math.tan(LatRad);
|
||||||
|
C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
|
||||||
|
A = Math.cos(LatRad) * (LongRad - LongOriginRad);
|
||||||
|
|
||||||
|
M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - (35 * eccSquared * eccSquared * eccSquared / 3072) * Math.sin(6 * LatRad));
|
||||||
|
|
||||||
|
var UTMEasting = (k0 * N * (A + (1 - T + C) * A * A * A / 6.0 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0);
|
||||||
|
|
||||||
|
var UTMNorthing = (k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24.0 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720.0)));
|
||||||
|
if (Lat < 0.0) {
|
||||||
|
UTMNorthing += 10000000.0; //10000000 meter offset for
|
||||||
|
// southern hemisphere
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
northing: Math.round(UTMNorthing),
|
||||||
|
easting: Math.round(UTMEasting),
|
||||||
|
zoneNumber: ZoneNumber,
|
||||||
|
zoneLetter: getLetterDesignator(Lat)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts UTM coords to lat/long, using the WGS84 ellipsoid. This is a convenience
|
||||||
|
* class where the Zone can be specified as a single string eg."60N" which
|
||||||
|
* is then broken down into the ZoneNumber and ZoneLetter.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} utm An object literal with northing, easting, zoneNumber
|
||||||
|
* and zoneLetter properties. If an optional accuracy property is
|
||||||
|
* provided (in meters), a bounding box will be returned instead of
|
||||||
|
* latitude and longitude.
|
||||||
|
* @return {object} An object literal containing either lat and lon values
|
||||||
|
* (if no accuracy was provided), or top, right, bottom and left values
|
||||||
|
* for the bounding box calculated according to the provided accuracy.
|
||||||
|
* Returns null if the conversion failed.
|
||||||
|
*/
|
||||||
|
function UTMtoLL(utm) {
|
||||||
|
|
||||||
|
var UTMNorthing = utm.northing;
|
||||||
|
var UTMEasting = utm.easting;
|
||||||
|
var zoneLetter = utm.zoneLetter;
|
||||||
|
var zoneNumber = utm.zoneNumber;
|
||||||
|
// check the ZoneNummber is valid
|
||||||
|
if (zoneNumber < 0 || zoneNumber > 60) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var k0 = 0.9996;
|
||||||
|
var a = 6378137.0; //ellip.radius;
|
||||||
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
||||||
|
var eccPrimeSquared;
|
||||||
|
var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));
|
||||||
|
var N1, T1, C1, R1, D, M;
|
||||||
|
var LongOrigin;
|
||||||
|
var mu, phi1Rad;
|
||||||
|
|
||||||
|
// remove 500,000 meter offset for longitude
|
||||||
|
var x = UTMEasting - 500000.0;
|
||||||
|
var y = UTMNorthing;
|
||||||
|
|
||||||
|
// We must know somehow if we are in the Northern or Southern
|
||||||
|
// hemisphere, this is the only time we use the letter So even
|
||||||
|
// if the Zone letter isn't exactly correct it should indicate
|
||||||
|
// the hemisphere correctly
|
||||||
|
if (zoneLetter < 'N') {
|
||||||
|
y -= 10000000.0; // remove 10,000,000 meter offset used
|
||||||
|
// for southern hemisphere
|
||||||
|
}
|
||||||
|
|
||||||
|
// There are 60 zones with zone 1 being at West -180 to -174
|
||||||
|
LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin
|
||||||
|
// in middle of
|
||||||
|
// zone
|
||||||
|
|
||||||
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
||||||
|
|
||||||
|
M = y / k0;
|
||||||
|
mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
|
||||||
|
|
||||||
|
phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.sin(6 * mu);
|
||||||
|
// double phi1 = ProjMath.radToDeg(phi1Rad);
|
||||||
|
|
||||||
|
N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));
|
||||||
|
T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);
|
||||||
|
C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);
|
||||||
|
R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);
|
||||||
|
D = x / (N1 * k0);
|
||||||
|
|
||||||
|
var lat = phi1Rad - (N1 * Math.tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);
|
||||||
|
lat = radToDeg(lat);
|
||||||
|
|
||||||
|
var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);
|
||||||
|
lon = LongOrigin + radToDeg(lon);
|
||||||
|
|
||||||
|
var result;
|
||||||
|
if (utm.accuracy) {
|
||||||
|
var topRight = UTMtoLL({
|
||||||
|
northing: utm.northing + utm.accuracy,
|
||||||
|
easting: utm.easting + utm.accuracy,
|
||||||
|
zoneLetter: utm.zoneLetter,
|
||||||
|
zoneNumber: utm.zoneNumber
|
||||||
|
});
|
||||||
|
result = {
|
||||||
|
top: topRight.lat,
|
||||||
|
right: topRight.lon,
|
||||||
|
bottom: lat,
|
||||||
|
left: lon
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = {
|
||||||
|
lat: lat,
|
||||||
|
lon: lon
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the MGRS letter designator for the given latitude.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} lat The latitude in WGS84 to get the letter designator
|
||||||
|
* for.
|
||||||
|
* @return {char} The letter designator.
|
||||||
|
*/
|
||||||
|
function getLetterDesignator(lat) {
|
||||||
|
//This is here as an error flag to show that the Latitude is
|
||||||
|
//outside MGRS limits
|
||||||
|
var LetterDesignator = 'Z';
|
||||||
|
|
||||||
|
if ((84 >= lat) && (lat >= 72)) {
|
||||||
|
LetterDesignator = 'X';
|
||||||
|
}
|
||||||
|
else if ((72 > lat) && (lat >= 64)) {
|
||||||
|
LetterDesignator = 'W';
|
||||||
|
}
|
||||||
|
else if ((64 > lat) && (lat >= 56)) {
|
||||||
|
LetterDesignator = 'V';
|
||||||
|
}
|
||||||
|
else if ((56 > lat) && (lat >= 48)) {
|
||||||
|
LetterDesignator = 'U';
|
||||||
|
}
|
||||||
|
else if ((48 > lat) && (lat >= 40)) {
|
||||||
|
LetterDesignator = 'T';
|
||||||
|
}
|
||||||
|
else if ((40 > lat) && (lat >= 32)) {
|
||||||
|
LetterDesignator = 'S';
|
||||||
|
}
|
||||||
|
else if ((32 > lat) && (lat >= 24)) {
|
||||||
|
LetterDesignator = 'R';
|
||||||
|
}
|
||||||
|
else if ((24 > lat) && (lat >= 16)) {
|
||||||
|
LetterDesignator = 'Q';
|
||||||
|
}
|
||||||
|
else if ((16 > lat) && (lat >= 8)) {
|
||||||
|
LetterDesignator = 'P';
|
||||||
|
}
|
||||||
|
else if ((8 > lat) && (lat >= 0)) {
|
||||||
|
LetterDesignator = 'N';
|
||||||
|
}
|
||||||
|
else if ((0 > lat) && (lat >= -8)) {
|
||||||
|
LetterDesignator = 'M';
|
||||||
|
}
|
||||||
|
else if ((-8 > lat) && (lat >= -16)) {
|
||||||
|
LetterDesignator = 'L';
|
||||||
|
}
|
||||||
|
else if ((-16 > lat) && (lat >= -24)) {
|
||||||
|
LetterDesignator = 'K';
|
||||||
|
}
|
||||||
|
else if ((-24 > lat) && (lat >= -32)) {
|
||||||
|
LetterDesignator = 'J';
|
||||||
|
}
|
||||||
|
else if ((-32 > lat) && (lat >= -40)) {
|
||||||
|
LetterDesignator = 'H';
|
||||||
|
}
|
||||||
|
else if ((-40 > lat) && (lat >= -48)) {
|
||||||
|
LetterDesignator = 'G';
|
||||||
|
}
|
||||||
|
else if ((-48 > lat) && (lat >= -56)) {
|
||||||
|
LetterDesignator = 'F';
|
||||||
|
}
|
||||||
|
else if ((-56 > lat) && (lat >= -64)) {
|
||||||
|
LetterDesignator = 'E';
|
||||||
|
}
|
||||||
|
else if ((-64 > lat) && (lat >= -72)) {
|
||||||
|
LetterDesignator = 'D';
|
||||||
|
}
|
||||||
|
else if ((-72 > lat) && (lat >= -80)) {
|
||||||
|
LetterDesignator = 'C';
|
||||||
|
}
|
||||||
|
return LetterDesignator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a UTM location as MGRS string.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {object} utm An object literal with easting, northing,
|
||||||
|
* zoneLetter, zoneNumber
|
||||||
|
* @param {number} accuracy Accuracy in digits (1-5).
|
||||||
|
* @return {string} MGRS string for the given UTM location.
|
||||||
|
*/
|
||||||
|
function encode(utm, accuracy) {
|
||||||
|
// prepend with leading zeroes
|
||||||
|
var seasting = "00000" + utm.easting,
|
||||||
|
snorthing = "00000" + utm.northing;
|
||||||
|
|
||||||
|
return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the two letter 100k designator for a given UTM easting,
|
||||||
|
* northing and zone number value.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} easting
|
||||||
|
* @param {number} northing
|
||||||
|
* @param {number} zoneNumber
|
||||||
|
* @return the two letter 100k designator for the given UTM location.
|
||||||
|
*/
|
||||||
|
function get100kID(easting, northing, zoneNumber) {
|
||||||
|
var setParm = get100kSetForZone(zoneNumber);
|
||||||
|
var setColumn = Math.floor(easting / 100000);
|
||||||
|
var setRow = Math.floor(northing / 100000) % 20;
|
||||||
|
return getLetter100kID(setColumn, setRow, setParm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a UTM zone number, figure out the MGRS 100K set it is in.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} i An UTM zone number.
|
||||||
|
* @return {number} the 100k set the UTM zone is in.
|
||||||
|
*/
|
||||||
|
function get100kSetForZone(i) {
|
||||||
|
var setParm = i % NUM_100K_SETS;
|
||||||
|
if (setParm === 0) {
|
||||||
|
setParm = NUM_100K_SETS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setParm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the two-letter MGRS 100k designator given information
|
||||||
|
* translated from the UTM northing, easting and zone number.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} column the column index as it relates to the MGRS
|
||||||
|
* 100k set spreadsheet, created from the UTM easting.
|
||||||
|
* Values are 1-8.
|
||||||
|
* @param {number} row the row index as it relates to the MGRS 100k set
|
||||||
|
* spreadsheet, created from the UTM northing value. Values
|
||||||
|
* are from 0-19.
|
||||||
|
* @param {number} parm the set block, as it relates to the MGRS 100k set
|
||||||
|
* spreadsheet, created from the UTM zone. Values are from
|
||||||
|
* 1-60.
|
||||||
|
* @return two letter MGRS 100k code.
|
||||||
|
*/
|
||||||
|
function getLetter100kID(column, row, parm) {
|
||||||
|
// colOrigin and rowOrigin are the letters at the origin of the set
|
||||||
|
var index = parm - 1;
|
||||||
|
var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);
|
||||||
|
var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);
|
||||||
|
|
||||||
|
// colInt and rowInt are the letters to build to return
|
||||||
|
var colInt = colOrigin + column - 1;
|
||||||
|
var rowInt = rowOrigin + row;
|
||||||
|
var rollover = false;
|
||||||
|
|
||||||
|
if (colInt > Z) {
|
||||||
|
colInt = colInt - Z + A - 1;
|
||||||
|
rollover = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt === I || (colOrigin < I && colInt > I) || ((colInt > I || colOrigin < I) && rollover)) {
|
||||||
|
colInt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt === O || (colOrigin < O && colInt > O) || ((colInt > O || colOrigin < O) && rollover)) {
|
||||||
|
colInt++;
|
||||||
|
|
||||||
|
if (colInt === I) {
|
||||||
|
colInt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colInt > Z) {
|
||||||
|
colInt = colInt - Z + A - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowInt > V) {
|
||||||
|
rowInt = rowInt - V + A - 1;
|
||||||
|
rollover = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rollover = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((rowInt === I) || ((rowOrigin < I) && (rowInt > I))) || (((rowInt > I) || (rowOrigin < I)) && rollover)) {
|
||||||
|
rowInt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((rowInt === O) || ((rowOrigin < O) && (rowInt > O))) || (((rowInt > O) || (rowOrigin < O)) && rollover)) {
|
||||||
|
rowInt++;
|
||||||
|
|
||||||
|
if (rowInt === I) {
|
||||||
|
rowInt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowInt > V) {
|
||||||
|
rowInt = rowInt - V + A - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);
|
||||||
|
return twoLetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the UTM parameters from a MGRS string.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {string} mgrsString an UPPERCASE coordinate string is expected.
|
||||||
|
* @return {object} An object literal with easting, northing, zoneLetter,
|
||||||
|
* zoneNumber and accuracy (in meters) properties.
|
||||||
|
*/
|
||||||
|
function decode(mgrsString) {
|
||||||
|
|
||||||
|
if (mgrsString && mgrsString.length === 0) {
|
||||||
|
throw ("MGRSPoint coverting from nothing");
|
||||||
|
}
|
||||||
|
|
||||||
|
var length = mgrsString.length;
|
||||||
|
|
||||||
|
var hunK = null;
|
||||||
|
var sb = "";
|
||||||
|
var testChar;
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
// get Zone number
|
||||||
|
while (!(/[A-Z]/).test(testChar = mgrsString.charAt(i))) {
|
||||||
|
if (i >= 2) {
|
||||||
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
||||||
|
}
|
||||||
|
sb += testChar;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var zoneNumber = parseInt(sb, 10);
|
||||||
|
|
||||||
|
if (i === 0 || i + 3 > length) {
|
||||||
|
// A good MGRS string has to be 4-5 digits long,
|
||||||
|
// ##AAA/#AAA at least.
|
||||||
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
var zoneLetter = mgrsString.charAt(i++);
|
||||||
|
|
||||||
|
// Should we check the zone letter here? Why not.
|
||||||
|
if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {
|
||||||
|
throw ("MGRSPoint zone letter " + zoneLetter + " not handled: " + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
hunK = mgrsString.substring(i, i += 2);
|
||||||
|
|
||||||
|
var set = get100kSetForZone(zoneNumber);
|
||||||
|
|
||||||
|
var east100k = getEastingFromChar(hunK.charAt(0), set);
|
||||||
|
var north100k = getNorthingFromChar(hunK.charAt(1), set);
|
||||||
|
|
||||||
|
// We have a bug where the northing may be 2000000 too low.
|
||||||
|
// How
|
||||||
|
// do we know when to roll over?
|
||||||
|
|
||||||
|
while (north100k < getMinNorthing(zoneLetter)) {
|
||||||
|
north100k += 2000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the char index for easting/northing separator
|
||||||
|
var remainder = length - i;
|
||||||
|
|
||||||
|
if (remainder % 2 !== 0) {
|
||||||
|
throw ("MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters" + mgrsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sep = remainder / 2;
|
||||||
|
|
||||||
|
var sepEasting = 0.0;
|
||||||
|
var sepNorthing = 0.0;
|
||||||
|
var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;
|
||||||
|
if (sep > 0) {
|
||||||
|
accuracyBonus = 100000.0 / Math.pow(10, sep);
|
||||||
|
sepEastingString = mgrsString.substring(i, i + sep);
|
||||||
|
sepEasting = parseFloat(sepEastingString) * accuracyBonus;
|
||||||
|
sepNorthingString = mgrsString.substring(i + sep);
|
||||||
|
sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
easting = sepEasting + east100k;
|
||||||
|
northing = sepNorthing + north100k;
|
||||||
|
|
||||||
|
return {
|
||||||
|
easting: easting,
|
||||||
|
northing: northing,
|
||||||
|
zoneLetter: zoneLetter,
|
||||||
|
zoneNumber: zoneNumber,
|
||||||
|
accuracy: accuracyBonus
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the first letter from a two-letter MGRS 100k zone, and given the
|
||||||
|
* MGRS table set for the zone number, figure out the easting value that
|
||||||
|
* should be added to the other, secondary easting value.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} e The first letter from a two-letter MGRS 100´k zone.
|
||||||
|
* @param {number} set The MGRS table set for the zone number.
|
||||||
|
* @return {number} The easting value for the given letter and set.
|
||||||
|
*/
|
||||||
|
function getEastingFromChar(e, set) {
|
||||||
|
// colOrigin is the letter at the origin of the set for the
|
||||||
|
// column
|
||||||
|
var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);
|
||||||
|
var eastingValue = 100000.0;
|
||||||
|
var rewindMarker = false;
|
||||||
|
|
||||||
|
while (curCol !== e.charCodeAt(0)) {
|
||||||
|
curCol++;
|
||||||
|
if (curCol === I) {
|
||||||
|
curCol++;
|
||||||
|
}
|
||||||
|
if (curCol === O) {
|
||||||
|
curCol++;
|
||||||
|
}
|
||||||
|
if (curCol > Z) {
|
||||||
|
if (rewindMarker) {
|
||||||
|
throw ("Bad character: " + e);
|
||||||
|
}
|
||||||
|
curCol = A;
|
||||||
|
rewindMarker = true;
|
||||||
|
}
|
||||||
|
eastingValue += 100000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return eastingValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the second letter from a two-letter MGRS 100k zone, and given the
|
||||||
|
* MGRS table set for the zone number, figure out the northing value that
|
||||||
|
* should be added to the other, secondary northing value. You have to
|
||||||
|
* remember that Northings are determined from the equator, and the vertical
|
||||||
|
* cycle of letters mean a 2000000 additional northing meters. This happens
|
||||||
|
* approx. every 18 degrees of latitude. This method does *NOT* count any
|
||||||
|
* additional northings. You have to figure out how many 2000000 meters need
|
||||||
|
* to be added for the zone letter of the MGRS coordinate.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} n Second letter of the MGRS 100k zone
|
||||||
|
* @param {number} set The MGRS table set number, which is dependent on the
|
||||||
|
* UTM zone number.
|
||||||
|
* @return {number} The northing value for the given letter and set.
|
||||||
|
*/
|
||||||
|
function getNorthingFromChar(n, set) {
|
||||||
|
|
||||||
|
if (n > 'V') {
|
||||||
|
throw ("MGRSPoint given invalid Northing " + n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rowOrigin is the letter at the origin of the set for the
|
||||||
|
// column
|
||||||
|
var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);
|
||||||
|
var northingValue = 0.0;
|
||||||
|
var rewindMarker = false;
|
||||||
|
|
||||||
|
while (curRow !== n.charCodeAt(0)) {
|
||||||
|
curRow++;
|
||||||
|
if (curRow === I) {
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
if (curRow === O) {
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
// fixing a bug making whole application hang in this loop
|
||||||
|
// when 'n' is a wrong character
|
||||||
|
if (curRow > V) {
|
||||||
|
if (rewindMarker) { // making sure that this loop ends
|
||||||
|
throw ("Bad character: " + n);
|
||||||
|
}
|
||||||
|
curRow = A;
|
||||||
|
rewindMarker = true;
|
||||||
|
}
|
||||||
|
northingValue += 100000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return northingValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function getMinNorthing returns the minimum northing value of a MGRS
|
||||||
|
* zone.
|
||||||
|
*
|
||||||
|
* Ported from Geotrans' c Lattitude_Band_Value structure table.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {char} zoneLetter The MGRS zone to get the min northing for.
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
function getMinNorthing(zoneLetter) {
|
||||||
|
var northing;
|
||||||
|
switch (zoneLetter) {
|
||||||
|
case 'C':
|
||||||
|
northing = 1100000.0;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
northing = 2000000.0;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
northing = 2800000.0;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
northing = 3700000.0;
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
northing = 4600000.0;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
northing = 5500000.0;
|
||||||
|
break;
|
||||||
|
case 'J':
|
||||||
|
northing = 6400000.0;
|
||||||
|
break;
|
||||||
|
case 'K':
|
||||||
|
northing = 7300000.0;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
northing = 8200000.0;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
northing = 9100000.0;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
northing = 0.0;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
northing = 800000.0;
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
northing = 1700000.0;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
northing = 2600000.0;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
northing = 3500000.0;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
northing = 4400000.0;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
northing = 5300000.0;
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
northing = 6200000.0;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
northing = 7000000.0;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
northing = 7900000.0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
northing = -1.0;
|
||||||
|
}
|
||||||
|
if (northing >= 0.0) {
|
||||||
|
return northing;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw ("Invalid zone letter: " + zoneLetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
145
node_modules/mgrs/openmap.md
generated
vendored
Normal file
145
node_modules/mgrs/openmap.md
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
OpenMap Software License Agreement
|
||||||
|
======
|
||||||
|
|
||||||
|
This Agreement sets forth the terms and conditions under which
|
||||||
|
the software known as OpenMap(tm) will be licensed by BBN
|
||||||
|
Technologies ("BBN") to you ("Licensee"), and by which Derivative
|
||||||
|
Works (as hereafter defined) of OpenMap will be licensed by you to BBN.
|
||||||
|
|
||||||
|
Definitions:
|
||||||
|
|
||||||
|
- "Derivative Work(s)" shall mean any revision, enhancement,
|
||||||
|
modification, translation, abridgement, condensation or
|
||||||
|
expansion created by Licensee or BBN that is based upon the
|
||||||
|
Software or a portion thereof that would be a copyright
|
||||||
|
infringement if prepared without the authorization of the
|
||||||
|
copyright owners of the Software or portion thereof.
|
||||||
|
|
||||||
|
- "OpenMap" shall mean a programmer's toolkit for building map
|
||||||
|
based applications as originally created by BBN, and any
|
||||||
|
Derivative Works thereof as created by either BBN or Licensee,
|
||||||
|
but shall include only those Derivative Works BBN has approved
|
||||||
|
for inclusion into, and BBN has integrated into OpenMap.
|
||||||
|
|
||||||
|
- "Standard Version" shall mean OpenMap, as originally created by
|
||||||
|
BBN.
|
||||||
|
|
||||||
|
- "Software" shall mean OpenMap and the Derivative Works created
|
||||||
|
by Licensee and the collection of files distributed by the
|
||||||
|
Licensee with OpenMap, and the collection of files created
|
||||||
|
through textual modifications.
|
||||||
|
|
||||||
|
- "Copyright Holder" is whoever is named in the copyright or
|
||||||
|
copyrights for the Derivative Works.
|
||||||
|
|
||||||
|
- "Licensee" is you, only if you agree to be bound by the terms
|
||||||
|
and conditions set forth in this Agreement.
|
||||||
|
|
||||||
|
- "Reasonable copying fee" is whatever you can justify on the
|
||||||
|
basis of media cost, duplication charges, time of people
|
||||||
|
involved.
|
||||||
|
|
||||||
|
- "Freely Available" means that no fee is charged for the item
|
||||||
|
itself, though there may be fees involved in handling the item.
|
||||||
|
It also means that recipients of the item may redistribute it
|
||||||
|
under the same conditions that they received it.
|
||||||
|
|
||||||
|
1. BBN maintains all rights, title and interest in and to
|
||||||
|
OpenMap, including all applicable copyrights, trade secrets,
|
||||||
|
patents and other intellectual rights therein. Licensee hereby
|
||||||
|
grants to BBN all right, title and interest into the compilation
|
||||||
|
of OpenMap. Licensee shall own all rights, title and interest
|
||||||
|
into the Derivative Works created by Licensee (subject to the
|
||||||
|
compilation ownership by BBN).
|
||||||
|
|
||||||
|
2. BBN hereby grants to Licensee a royalty free, worldwide right
|
||||||
|
and license to use, copy, distribute and make Derivative Works of
|
||||||
|
OpenMap, and sublicensing rights of any of the foregoing in
|
||||||
|
accordance with the terms and conditions of this Agreement,
|
||||||
|
provided that you duplicate all of the original copyright notices
|
||||||
|
and associated disclaimers.
|
||||||
|
|
||||||
|
3. Licensee hereby grants to BBN a royalty free, worldwide right
|
||||||
|
and license to use, copy, distribute and make Derivative Works of
|
||||||
|
Derivative Works created by Licensee and sublicensing rights of
|
||||||
|
any of the foregoing.
|
||||||
|
|
||||||
|
4. Licensee's right to create Derivative Works in the Software is
|
||||||
|
subject to Licensee agreement to insert a prominent notice in
|
||||||
|
each changed file stating how and when you changed that file, and
|
||||||
|
provided that you do at least ONE of the following:
|
||||||
|
|
||||||
|
- a) place your modifications in the Public Domain or otherwise
|
||||||
|
make them Freely Available, such as by posting said
|
||||||
|
modifications to Usenet or an equivalent medium, or
|
||||||
|
placing the modifications on a major archive site and by
|
||||||
|
providing your modifications to the Copyright Holder.
|
||||||
|
|
||||||
|
- b) use the modified Package only within your corporation or
|
||||||
|
organization.
|
||||||
|
|
||||||
|
- c) rename any non-standard executables so the names do not
|
||||||
|
conflict with standard executables, which must also be
|
||||||
|
provided, and provide a separate manual page for each
|
||||||
|
non-standard executable that clearly documents how it
|
||||||
|
differs from OpenMap.
|
||||||
|
|
||||||
|
- d) make other distribution arrangements with the Copyright
|
||||||
|
Holder.
|
||||||
|
5. Licensee may distribute the programs of this Software in
|
||||||
|
object code or executable form, provided that you do at least ONE
|
||||||
|
of the following:
|
||||||
|
|
||||||
|
- a) distribute an OpenMap version of the executables and
|
||||||
|
library files, together with instructions (in the manual
|
||||||
|
page or equivalent) on where to get OpenMap.
|
||||||
|
|
||||||
|
- b) accompany the distribution with the machine-readable
|
||||||
|
source code with your modifications.
|
||||||
|
|
||||||
|
- c) accompany any non-standard executables with their
|
||||||
|
corresponding OpenMap executables, giving the non-standard
|
||||||
|
executables non-standard names, and clearly documenting
|
||||||
|
the differences in manual pages (or equivalent), together
|
||||||
|
with instructions on where to get OpenMap.
|
||||||
|
|
||||||
|
- d) make other distribution arrangements with the Copyright
|
||||||
|
Holder.
|
||||||
|
6. You may charge a reasonable copying fee for any distribution
|
||||||
|
of this Software. You may charge any fee you choose for support
|
||||||
|
of this Software. You may not charge a fee for this Software
|
||||||
|
itself. However, you may distribute this Software in aggregate
|
||||||
|
with other (possibly commercial) programs as part of a larger
|
||||||
|
(possibly commercial) software distribution provided that you do
|
||||||
|
not advertise this Software as a product of your own.
|
||||||
|
|
||||||
|
7. The data and images supplied as input to or produced as output
|
||||||
|
from the Software do not automatically fall under the copyright
|
||||||
|
of this Software, but belong to whomever generated them, and may
|
||||||
|
be sold commercially, and may be aggregated with this Software.
|
||||||
|
|
||||||
|
8. BBN makes no representation about the suitability of OpenMap
|
||||||
|
for any purposes. BBN shall have no duty or requirement to
|
||||||
|
include any Derivative Works into OpenMap.
|
||||||
|
|
||||||
|
9. Each party hereto represents and warrants that they have the
|
||||||
|
full unrestricted right to grant all rights and licenses granted
|
||||||
|
to the other party herein.
|
||||||
|
|
||||||
|
10. THIS PACKAGE IS PROVIDED "AS IS" WITHOUT WARRANTIES OF ANY
|
||||||
|
KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING (BUT NOT LIMITED TO)
|
||||||
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND
|
||||||
|
WITHOUT ANY WARRANTIES AS TO NONINFRINGEMENT.
|
||||||
|
|
||||||
|
11. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT,
|
||||||
|
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER RESULTING
|
||||||
|
FROM LOSS OF USE OF DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||||
|
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS CONDUCT, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS PACKAGE.
|
||||||
|
|
||||||
|
12. Without limitation of the foregoing, You agree to commit no
|
||||||
|
act which, directly or indirectly, would violate any U.S. law,
|
||||||
|
regulation, or treaty, or any other international treaty or
|
||||||
|
agreement to which the United States adheres or with which the
|
||||||
|
United States complies, relating to the export or re-export of
|
||||||
|
any commodities, software, or technical data.
|
31
node_modules/mgrs/package.json
generated
vendored
Normal file
31
node_modules/mgrs/package.json
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"name": "mgrs",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Utility for converting between WGS84 lat/lng and MGRS coordinates",
|
||||||
|
"main": "dist/mgrs.js",
|
||||||
|
"module": "mgrs.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "npm run build && istanbul test _mocha test/test.js",
|
||||||
|
"build": "mkdir -p dist && rollup -c"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/proj4js/mgrs.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"mgrs",
|
||||||
|
"proj4",
|
||||||
|
"gis"
|
||||||
|
],
|
||||||
|
"author": "proj4 team",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/proj4js/mgrs/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"rollup": "^0.41.4",
|
||||||
|
"chai": "~1.8.1",
|
||||||
|
"istanbul": "~0.1.46",
|
||||||
|
"mocha": "~1.15.1"
|
||||||
|
}
|
||||||
|
}
|
21
node_modules/mgrs/publish.sh
generated
vendored
Normal file
21
node_modules/mgrs/publish.sh
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# get current version
|
||||||
|
VERSION=$(npm ls --json=true mgrs | grep version | awk '{ print $2}'| sed -e 's/^"//' -e 's/"$//')
|
||||||
|
|
||||||
|
# Build
|
||||||
|
git checkout -b build
|
||||||
|
npm run build
|
||||||
|
git add dist -f
|
||||||
|
git commit -m "build $VERSION"
|
||||||
|
|
||||||
|
# Tag and push
|
||||||
|
git tag $VERSION
|
||||||
|
git push --tags git@github.com:proj4js/mgrs.git $VERSION
|
||||||
|
|
||||||
|
# Publish
|
||||||
|
npm publish
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
git checkout master
|
||||||
|
git branch -D build
|
44
node_modules/mgrs/readme.md
generated
vendored
Normal file
44
node_modules/mgrs/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
mgrs
|
||||||
|
====
|
||||||
|
|
||||||
|
Utility for converting between WGS84 lat/lng and MGRS coordinates, spunoff from [proj4js](https://github.com/proj4js/proj4js)
|
||||||
|
|
||||||
|
has 3 methods
|
||||||
|
|
||||||
|
- forward, takes an array of `[lon,lat]` and optional accuracy and returns an mgrs string
|
||||||
|
- inverse, takes an mgrs string and returns a bbox.
|
||||||
|
- toPoint, takes an mgrs string, returns an array of '[lon,lat]'
|
||||||
|
|
||||||
|
install dev dependencies with
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
test with
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
test coverage with
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test --coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
build with
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Licensed under the MIT license except:
|
||||||
|
|
||||||
|
Portions of this software are based on a port of components from the OpenMap
|
||||||
|
com.bbn.openmap.proj.coords Java package. An initial port was initially created
|
||||||
|
by Patrice G. Cappelaere and included in Community Mapbuilder
|
||||||
|
(http://svn.codehaus.org/mapbuilder/), which is licensed under the LGPL license
|
||||||
|
as per http://www.gnu.org/copyleft/lesser.html. OpenMap is licensed under the
|
||||||
|
[following license agreement](openmap.md):
|
8
node_modules/mgrs/rollup.config.js
generated
vendored
Normal file
8
node_modules/mgrs/rollup.config.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
export default {
|
||||||
|
entry: 'mgrs.js',
|
||||||
|
dest: 'dist/mgrs.js',
|
||||||
|
format: 'umd',
|
||||||
|
moduleName: 'mgrs',
|
||||||
|
exports: 'named'
|
||||||
|
};
|
37
node_modules/mgrs/test/test.js
generated
vendored
Normal file
37
node_modules/mgrs/test/test.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
var should = require('chai').should();
|
||||||
|
var mgrs = require('../dist/mgrs');
|
||||||
|
describe('First MGRS set', function() {
|
||||||
|
var mgrsStr = "33UXP04";
|
||||||
|
var point = mgrs.toPoint(mgrsStr);
|
||||||
|
it('Longitude of point from MGRS correct.', function() {
|
||||||
|
point[0].should.be.closeTo(16.41450, 0.000001);
|
||||||
|
});
|
||||||
|
it('Latitude of point from MGRS correct.', function() {
|
||||||
|
point[1].should.be.closeTo(48.24949, 0.000001);
|
||||||
|
});
|
||||||
|
it('MGRS reference with highest accuracy correct.', function() {
|
||||||
|
mgrs.forward(point).should.equal("33UXP0500444998");
|
||||||
|
});
|
||||||
|
it('MGRS reference with 1-digit accuracy correct.', function() {
|
||||||
|
mgrs.forward(point,1).should.equal(mgrsStr);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Second MGRS set', function() {
|
||||||
|
var mgrsStr = "24XWT783908"; // near UTM zone border, so there are two ways to reference this
|
||||||
|
var point = mgrs.toPoint(mgrsStr);
|
||||||
|
it('Longitude of point from MGRS correct.', function() {
|
||||||
|
point[0].should.be.closeTo(-32.66433, 0.00001);
|
||||||
|
});
|
||||||
|
it('Latitude of point from MGRS correct.', function() {
|
||||||
|
point[1].should.be.closeTo(83.62778, 0.00001);
|
||||||
|
});
|
||||||
|
it('MGRS reference with 1-digit accuracy correct.', function() {
|
||||||
|
mgrs.forward(point,3).should.equal('25XEN041865');
|
||||||
|
});
|
||||||
|
it('MGRS reference with 5-digit accuracy, northing all zeros', function(){
|
||||||
|
mgrs.forward([0,0],5).should.equal('31NAA6602100000');
|
||||||
|
});
|
||||||
|
it('MGRS reference with 5-digit accuracy, northing one digit', function(){
|
||||||
|
mgrs.forward([0,0.00001],5).should.equal('31NAA6602100001');
|
||||||
|
});
|
||||||
|
})
|
22
node_modules/node-fetch/LICENSE.md
generated
vendored
Normal file
22
node_modules/node-fetch/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 David Frank
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
633
node_modules/node-fetch/README.md
generated
vendored
Normal file
633
node_modules/node-fetch/README.md
generated
vendored
Normal file
|
@ -0,0 +1,633 @@
|
||||||
|
node-fetch
|
||||||
|
==========
|
||||||
|
|
||||||
|
[![npm version][npm-image]][npm-url]
|
||||||
|
[![build status][travis-image]][travis-url]
|
||||||
|
[![coverage status][codecov-image]][codecov-url]
|
||||||
|
[![install size][install-size-image]][install-size-url]
|
||||||
|
[![Discord][discord-image]][discord-url]
|
||||||
|
|
||||||
|
A light-weight module that brings `window.fetch` to Node.js
|
||||||
|
|
||||||
|
(We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567))
|
||||||
|
|
||||||
|
[![Backers][opencollective-image]][opencollective-url]
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Motivation](#motivation)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Difference from client-side fetch](#difference-from-client-side-fetch)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Loading and configuring the module](#loading-and-configuring-the-module)
|
||||||
|
- [Common Usage](#common-usage)
|
||||||
|
- [Plain text or HTML](#plain-text-or-html)
|
||||||
|
- [JSON](#json)
|
||||||
|
- [Simple Post](#simple-post)
|
||||||
|
- [Post with JSON](#post-with-json)
|
||||||
|
- [Post with form parameters](#post-with-form-parameters)
|
||||||
|
- [Handling exceptions](#handling-exceptions)
|
||||||
|
- [Handling client and server errors](#handling-client-and-server-errors)
|
||||||
|
- [Advanced Usage](#advanced-usage)
|
||||||
|
- [Streams](#streams)
|
||||||
|
- [Buffer](#buffer)
|
||||||
|
- [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data)
|
||||||
|
- [Extract Set-Cookie Header](#extract-set-cookie-header)
|
||||||
|
- [Post data using a file stream](#post-data-using-a-file-stream)
|
||||||
|
- [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart)
|
||||||
|
- [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal)
|
||||||
|
- [API](#api)
|
||||||
|
- [fetch(url[, options])](#fetchurl-options)
|
||||||
|
- [Options](#options)
|
||||||
|
- [Class: Request](#class-request)
|
||||||
|
- [Class: Response](#class-response)
|
||||||
|
- [Class: Headers](#class-headers)
|
||||||
|
- [Interface: Body](#interface-body)
|
||||||
|
- [Class: FetchError](#class-fetcherror)
|
||||||
|
- [License](#license)
|
||||||
|
- [Acknowledgement](#acknowledgement)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
|
Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime.
|
||||||
|
|
||||||
|
See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Stay consistent with `window.fetch` API.
|
||||||
|
- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences.
|
||||||
|
- Use native promise but allow substituting it with [insert your favorite promise library].
|
||||||
|
- Use native Node streams for body on both request and response.
|
||||||
|
- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically.
|
||||||
|
- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting.
|
||||||
|
|
||||||
|
## Difference from client-side fetch
|
||||||
|
|
||||||
|
- See [Known Differences](LIMITS.md) for details.
|
||||||
|
- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue.
|
||||||
|
- Pull requests are welcomed too!
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Current stable release (`2.x`)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install node-fetch
|
||||||
|
```
|
||||||
|
|
||||||
|
## Loading and configuring the module
|
||||||
|
We suggest you load the module via `require` until the stabilization of ES modules in node:
|
||||||
|
```js
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
```
|
||||||
|
|
||||||
|
If you are using a Promise library other than native, set it through `fetch.Promise`:
|
||||||
|
```js
|
||||||
|
const Bluebird = require('bluebird');
|
||||||
|
|
||||||
|
fetch.Promise = Bluebird;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Usage
|
||||||
|
|
||||||
|
NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences.
|
||||||
|
|
||||||
|
#### Plain text or HTML
|
||||||
|
```js
|
||||||
|
fetch('https://github.com/')
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(body => console.log(body));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### JSON
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
fetch('https://api.github.com/users/github')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Simple Post
|
||||||
|
```js
|
||||||
|
fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' })
|
||||||
|
.then(res => res.json()) // expecting a json response
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Post with JSON
|
||||||
|
|
||||||
|
```js
|
||||||
|
const body = { a: 1 };
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/post', {
|
||||||
|
method: 'post',
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Post with form parameters
|
||||||
|
`URLSearchParams` is available in Node.js as of v7.5.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods.
|
||||||
|
|
||||||
|
NOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { URLSearchParams } = require('url');
|
||||||
|
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('a', 1);
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/post', { method: 'POST', body: params })
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Handling exceptions
|
||||||
|
NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information.
|
||||||
|
|
||||||
|
Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details.
|
||||||
|
|
||||||
|
```js
|
||||||
|
fetch('https://domain.invalid/')
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Handling client and server errors
|
||||||
|
It is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses:
|
||||||
|
|
||||||
|
```js
|
||||||
|
function checkStatus(res) {
|
||||||
|
if (res.ok) { // res.status >= 200 && res.status < 300
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
throw MyCustomError(res.statusText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/status/400')
|
||||||
|
.then(checkStatus)
|
||||||
|
.then(res => console.log('will not get here...'))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Advanced Usage
|
||||||
|
|
||||||
|
#### Streams
|
||||||
|
The "Node.js way" is to use streams when possible:
|
||||||
|
|
||||||
|
```js
|
||||||
|
fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
|
||||||
|
.then(res => {
|
||||||
|
const dest = fs.createWriteStream('./octocat.png');
|
||||||
|
res.body.pipe(dest);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch
|
||||||
|
errors -- the longer a response runs, the more likely it is to encounter an error.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
const response = await fetch('https://httpbin.org/stream/3');
|
||||||
|
try {
|
||||||
|
for await (const chunk of response.body) {
|
||||||
|
console.dir(JSON.parse(chunk.toString()));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.stack);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In Node.js 12 you can also use async iterators to read `body`; however, async iterators with streams
|
||||||
|
did not mature until Node.js 14, so you need to do some extra work to ensure you handle errors
|
||||||
|
directly from the stream and wait on it response to fully close.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
const read = async body => {
|
||||||
|
let error;
|
||||||
|
body.on('error', err => {
|
||||||
|
error = err;
|
||||||
|
});
|
||||||
|
for await (const chunk of body) {
|
||||||
|
console.dir(JSON.parse(chunk.toString()));
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
body.on('close', () => {
|
||||||
|
error ? reject(error) : resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const response = await fetch('https://httpbin.org/stream/3');
|
||||||
|
await read(response.body);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.stack);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Buffer
|
||||||
|
If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const fileType = require('file-type');
|
||||||
|
|
||||||
|
fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
|
||||||
|
.then(res => res.buffer())
|
||||||
|
.then(buffer => fileType(buffer))
|
||||||
|
.then(type => { /* ... */ });
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Accessing Headers and other Meta data
|
||||||
|
```js
|
||||||
|
fetch('https://github.com/')
|
||||||
|
.then(res => {
|
||||||
|
console.log(res.ok);
|
||||||
|
console.log(res.status);
|
||||||
|
console.log(res.statusText);
|
||||||
|
console.log(res.headers.raw());
|
||||||
|
console.log(res.headers.get('content-type'));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Extract Set-Cookie Header
|
||||||
|
|
||||||
|
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API.
|
||||||
|
|
||||||
|
```js
|
||||||
|
fetch(url).then(res => {
|
||||||
|
// returns an array of values, instead of a string of comma-separated values
|
||||||
|
console.log(res.headers.raw()['set-cookie']);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Post data using a file stream
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { createReadStream } = require('fs');
|
||||||
|
|
||||||
|
const stream = createReadStream('input.txt');
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/post', { method: 'POST', body: stream })
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Post with form-data (detect multipart)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const FormData = require('form-data');
|
||||||
|
|
||||||
|
const form = new FormData();
|
||||||
|
form.append('a', 1);
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/post', { method: 'POST', body: form })
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
|
||||||
|
// OR, using custom headers
|
||||||
|
// NOTE: getHeaders() is non-standard API
|
||||||
|
|
||||||
|
const form = new FormData();
|
||||||
|
form.append('a', 1);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
body: form,
|
||||||
|
headers: form.getHeaders()
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch('https://httpbin.org/post', options)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.log(json));
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Request cancellation with AbortSignal
|
||||||
|
|
||||||
|
> NOTE: You may cancel streamed requests only on Node >= v8.0.0
|
||||||
|
|
||||||
|
You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller).
|
||||||
|
|
||||||
|
An example of timing out a request after 150ms could be achieved as the following:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import AbortController from 'abort-controller';
|
||||||
|
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timeout = setTimeout(
|
||||||
|
() => { controller.abort(); },
|
||||||
|
150,
|
||||||
|
);
|
||||||
|
|
||||||
|
fetch(url, { signal: controller.signal })
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(
|
||||||
|
data => {
|
||||||
|
useData(data)
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
if (err.name === 'AbortError') {
|
||||||
|
// request was aborted
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples.
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### fetch(url[, options])
|
||||||
|
|
||||||
|
- `url` A string representing the URL for fetching
|
||||||
|
- `options` [Options](#fetch-options) for the HTTP(S) request
|
||||||
|
- Returns: <code>Promise<[Response](#class-response)></code>
|
||||||
|
|
||||||
|
Perform an HTTP(S) fetch.
|
||||||
|
|
||||||
|
`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`.
|
||||||
|
|
||||||
|
<a id="fetch-options"></a>
|
||||||
|
### Options
|
||||||
|
|
||||||
|
The default values are shown after each option key.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
// These properties are part of the Fetch Standard
|
||||||
|
method: 'GET',
|
||||||
|
headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below)
|
||||||
|
body: null, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream
|
||||||
|
redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect
|
||||||
|
signal: null, // pass an instance of AbortSignal to optionally abort requests
|
||||||
|
|
||||||
|
// The following properties are node-fetch extensions
|
||||||
|
follow: 20, // maximum redirect count. 0 to not follow redirect
|
||||||
|
timeout: 0, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead.
|
||||||
|
compress: true, // support gzip/deflate content encoding. false to disable
|
||||||
|
size: 0, // maximum response body size in bytes. 0 to disable
|
||||||
|
agent: null // http(s).Agent instance or function that returns an instance (see below)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Default Headers
|
||||||
|
|
||||||
|
If no values are set, the following request headers will be sent automatically:
|
||||||
|
|
||||||
|
Header | Value
|
||||||
|
------------------- | --------------------------------------------------------
|
||||||
|
`Accept-Encoding` | `gzip,deflate` _(when `options.compress === true`)_
|
||||||
|
`Accept` | `*/*`
|
||||||
|
`Connection` | `close` _(when no `options.agent` is present)_
|
||||||
|
`Content-Length` | _(automatically calculated, if possible)_
|
||||||
|
`Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_
|
||||||
|
`User-Agent` | `node-fetch/1.0 (+https://github.com/bitinn/node-fetch)`
|
||||||
|
|
||||||
|
Note: when `body` is a `Stream`, `Content-Length` is not set automatically.
|
||||||
|
|
||||||
|
##### Custom Agent
|
||||||
|
|
||||||
|
The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following:
|
||||||
|
|
||||||
|
- Support self-signed certificate
|
||||||
|
- Use only IPv4 or IPv6
|
||||||
|
- Custom DNS Lookup
|
||||||
|
|
||||||
|
See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information.
|
||||||
|
|
||||||
|
In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const httpAgent = new http.Agent({
|
||||||
|
keepAlive: true
|
||||||
|
});
|
||||||
|
const httpsAgent = new https.Agent({
|
||||||
|
keepAlive: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
agent: function (_parsedURL) {
|
||||||
|
if (_parsedURL.protocol == 'http:') {
|
||||||
|
return httpAgent;
|
||||||
|
} else {
|
||||||
|
return httpsAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="class-request"></a>
|
||||||
|
### Class: Request
|
||||||
|
|
||||||
|
An HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface.
|
||||||
|
|
||||||
|
Due to the nature of Node.js, the following properties are not implemented at this moment:
|
||||||
|
|
||||||
|
- `type`
|
||||||
|
- `destination`
|
||||||
|
- `referrer`
|
||||||
|
- `referrerPolicy`
|
||||||
|
- `mode`
|
||||||
|
- `credentials`
|
||||||
|
- `cache`
|
||||||
|
- `integrity`
|
||||||
|
- `keepalive`
|
||||||
|
|
||||||
|
The following node-fetch extension properties are provided:
|
||||||
|
|
||||||
|
- `follow`
|
||||||
|
- `compress`
|
||||||
|
- `counter`
|
||||||
|
- `agent`
|
||||||
|
|
||||||
|
See [options](#fetch-options) for exact meaning of these extensions.
|
||||||
|
|
||||||
|
#### new Request(input[, options])
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
- `input` A string representing a URL, or another `Request` (which will be cloned)
|
||||||
|
- `options` [Options][#fetch-options] for the HTTP(S) request
|
||||||
|
|
||||||
|
Constructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).
|
||||||
|
|
||||||
|
In most cases, directly `fetch(url, options)` is simpler than creating a `Request` object.
|
||||||
|
|
||||||
|
<a id="class-response"></a>
|
||||||
|
### Class: Response
|
||||||
|
|
||||||
|
An HTTP(S) response. This class implements the [Body](#iface-body) interface.
|
||||||
|
|
||||||
|
The following properties are not implemented in node-fetch at this moment:
|
||||||
|
|
||||||
|
- `Response.error()`
|
||||||
|
- `Response.redirect()`
|
||||||
|
- `type`
|
||||||
|
- `trailer`
|
||||||
|
|
||||||
|
#### new Response([body[, options]])
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
- `body` A `String` or [`Readable` stream][node-readable]
|
||||||
|
- `options` A [`ResponseInit`][response-init] options dictionary
|
||||||
|
|
||||||
|
Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response).
|
||||||
|
|
||||||
|
Because Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly.
|
||||||
|
|
||||||
|
#### response.ok
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
Convenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300.
|
||||||
|
|
||||||
|
#### response.redirected
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
Convenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0.
|
||||||
|
|
||||||
|
<a id="class-headers"></a>
|
||||||
|
### Class: Headers
|
||||||
|
|
||||||
|
This class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented.
|
||||||
|
|
||||||
|
#### new Headers([init])
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
- `init` Optional argument to pre-fill the `Headers` object
|
||||||
|
|
||||||
|
Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
'Content-Type': 'text/xml',
|
||||||
|
'Breaking-Bad': '<3'
|
||||||
|
};
|
||||||
|
const headers = new Headers(meta);
|
||||||
|
|
||||||
|
// The above is equivalent to
|
||||||
|
const meta = [
|
||||||
|
[ 'Content-Type', 'text/xml' ],
|
||||||
|
[ 'Breaking-Bad', '<3' ]
|
||||||
|
];
|
||||||
|
const headers = new Headers(meta);
|
||||||
|
|
||||||
|
// You can in fact use any iterable objects, like a Map or even another Headers
|
||||||
|
const meta = new Map();
|
||||||
|
meta.set('Content-Type', 'text/xml');
|
||||||
|
meta.set('Breaking-Bad', '<3');
|
||||||
|
const headers = new Headers(meta);
|
||||||
|
const copyOfHeaders = new Headers(headers);
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="iface-body"></a>
|
||||||
|
### Interface: Body
|
||||||
|
|
||||||
|
`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes.
|
||||||
|
|
||||||
|
The following methods are not yet implemented in node-fetch at this moment:
|
||||||
|
|
||||||
|
- `formData()`
|
||||||
|
|
||||||
|
#### body.body
|
||||||
|
|
||||||
|
<small>*(deviation from spec)*</small>
|
||||||
|
|
||||||
|
* Node.js [`Readable` stream][node-readable]
|
||||||
|
|
||||||
|
Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable].
|
||||||
|
|
||||||
|
#### body.bodyUsed
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
* `Boolean`
|
||||||
|
|
||||||
|
A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again.
|
||||||
|
|
||||||
|
#### body.arrayBuffer()
|
||||||
|
#### body.blob()
|
||||||
|
#### body.json()
|
||||||
|
#### body.text()
|
||||||
|
|
||||||
|
<small>*(spec-compliant)*</small>
|
||||||
|
|
||||||
|
* Returns: <code>Promise</code>
|
||||||
|
|
||||||
|
Consume the body and return a promise that will resolve to one of these formats.
|
||||||
|
|
||||||
|
#### body.buffer()
|
||||||
|
|
||||||
|
<small>*(node-fetch extension)*</small>
|
||||||
|
|
||||||
|
* Returns: <code>Promise<Buffer></code>
|
||||||
|
|
||||||
|
Consume the body and return a promise that will resolve to a Buffer.
|
||||||
|
|
||||||
|
#### body.textConverted()
|
||||||
|
|
||||||
|
<small>*(node-fetch extension)*</small>
|
||||||
|
|
||||||
|
* Returns: <code>Promise<String></code>
|
||||||
|
|
||||||
|
Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible.
|
||||||
|
|
||||||
|
(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.)
|
||||||
|
|
||||||
|
<a id="class-fetcherror"></a>
|
||||||
|
### Class: FetchError
|
||||||
|
|
||||||
|
<small>*(node-fetch extension)*</small>
|
||||||
|
|
||||||
|
An operational error in the fetching process. See [ERROR-HANDLING.md][] for more info.
|
||||||
|
|
||||||
|
<a id="class-aborterror"></a>
|
||||||
|
### Class: AbortError
|
||||||
|
|
||||||
|
<small>*(node-fetch extension)*</small>
|
||||||
|
|
||||||
|
An Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info.
|
||||||
|
|
||||||
|
## Acknowledgement
|
||||||
|
|
||||||
|
Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference.
|
||||||
|
|
||||||
|
`node-fetch` v1 was maintained by [@bitinn](https://github.com/bitinn); v2 was maintained by [@TimothyGu](https://github.com/timothygu), [@bitinn](https://github.com/bitinn) and [@jimmywarting](https://github.com/jimmywarting); v2 readme is written by [@jkantr](https://github.com/jkantr).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
[npm-image]: https://flat.badgen.net/npm/v/node-fetch
|
||||||
|
[npm-url]: https://www.npmjs.com/package/node-fetch
|
||||||
|
[travis-image]: https://flat.badgen.net/travis/bitinn/node-fetch
|
||||||
|
[travis-url]: https://travis-ci.org/bitinn/node-fetch
|
||||||
|
[codecov-image]: https://flat.badgen.net/codecov/c/github/bitinn/node-fetch/master
|
||||||
|
[codecov-url]: https://codecov.io/gh/bitinn/node-fetch
|
||||||
|
[install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch
|
||||||
|
[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch
|
||||||
|
[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA&label=Discord&style=flat-square
|
||||||
|
[discord-url]: https://discord.gg/Zxbndcm
|
||||||
|
[opencollective-image]: https://opencollective.com/node-fetch/backers.svg
|
||||||
|
[opencollective-url]: https://opencollective.com/node-fetch
|
||||||
|
[whatwg-fetch]: https://fetch.spec.whatwg.org/
|
||||||
|
[response-init]: https://fetch.spec.whatwg.org/#responseinit
|
||||||
|
[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams
|
||||||
|
[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers
|
||||||
|
[LIMITS.md]: https://github.com/bitinn/node-fetch/blob/master/LIMITS.md
|
||||||
|
[ERROR-HANDLING.md]: https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md
|
||||||
|
[UPGRADE-GUIDE.md]: https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md
|
25
node_modules/node-fetch/browser.js
generated
vendored
Normal file
25
node_modules/node-fetch/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// ref: https://github.com/tc39/proposal-global
|
||||||
|
var getGlobal = function () {
|
||||||
|
// the only reliable means to get the global object is
|
||||||
|
// `Function('return this')()`
|
||||||
|
// However, this causes CSP violations in Chrome apps.
|
||||||
|
if (typeof self !== 'undefined') { return self; }
|
||||||
|
if (typeof window !== 'undefined') { return window; }
|
||||||
|
if (typeof global !== 'undefined') { return global; }
|
||||||
|
throw new Error('unable to locate global object');
|
||||||
|
}
|
||||||
|
|
||||||
|
var globalObject = getGlobal();
|
||||||
|
|
||||||
|
module.exports = exports = globalObject.fetch;
|
||||||
|
|
||||||
|
// Needed for TypeScript and Webpack.
|
||||||
|
if (globalObject.fetch) {
|
||||||
|
exports.default = globalObject.fetch.bind(globalObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.Headers = globalObject.Headers;
|
||||||
|
exports.Request = globalObject.Request;
|
||||||
|
exports.Response = globalObject.Response;
|
1781
node_modules/node-fetch/lib/index.es.js
generated
vendored
Normal file
1781
node_modules/node-fetch/lib/index.es.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1790
node_modules/node-fetch/lib/index.js
generated
vendored
Normal file
1790
node_modules/node-fetch/lib/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1779
node_modules/node-fetch/lib/index.mjs
generated
vendored
Normal file
1779
node_modules/node-fetch/lib/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
89
node_modules/node-fetch/package.json
generated
vendored
Normal file
89
node_modules/node-fetch/package.json
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
{
|
||||||
|
"name": "node-fetch",
|
||||||
|
"version": "2.6.12",
|
||||||
|
"description": "A light-weight module that brings window.fetch to node.js",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"browser": "./browser.js",
|
||||||
|
"module": "lib/index.mjs",
|
||||||
|
"files": [
|
||||||
|
"lib/index.js",
|
||||||
|
"lib/index.mjs",
|
||||||
|
"lib/index.es.js",
|
||||||
|
"browser.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "cross-env BABEL_ENV=rollup rollup -c",
|
||||||
|
"prepare": "npm run build",
|
||||||
|
"test": "cross-env BABEL_ENV=test mocha --require babel-register --throw-deprecation test/test.js",
|
||||||
|
"report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js",
|
||||||
|
"coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/bitinn/node-fetch.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"fetch",
|
||||||
|
"http",
|
||||||
|
"promise"
|
||||||
|
],
|
||||||
|
"author": "David Frank",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/bitinn/node-fetch/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/bitinn/node-fetch",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@ungap/url-search-params": "^0.1.2",
|
||||||
|
"abort-controller": "^1.1.0",
|
||||||
|
"abortcontroller-polyfill": "^1.3.0",
|
||||||
|
"babel-core": "^6.26.3",
|
||||||
|
"babel-plugin-istanbul": "^4.1.6",
|
||||||
|
"babel-plugin-transform-async-generator-functions": "^6.24.1",
|
||||||
|
"babel-polyfill": "^6.26.0",
|
||||||
|
"babel-preset-env": "1.4.0",
|
||||||
|
"babel-register": "^6.16.3",
|
||||||
|
"chai": "^3.5.0",
|
||||||
|
"chai-as-promised": "^7.1.1",
|
||||||
|
"chai-iterator": "^1.1.1",
|
||||||
|
"chai-string": "~1.3.0",
|
||||||
|
"codecov": "3.3.0",
|
||||||
|
"cross-env": "^5.2.0",
|
||||||
|
"form-data": "^2.3.3",
|
||||||
|
"is-builtin-module": "^1.0.0",
|
||||||
|
"mocha": "^5.0.0",
|
||||||
|
"nyc": "11.9.0",
|
||||||
|
"parted": "^0.1.1",
|
||||||
|
"promise": "^8.0.3",
|
||||||
|
"resumer": "0.0.0",
|
||||||
|
"rollup": "^0.63.4",
|
||||||
|
"rollup-plugin-babel": "^3.0.7",
|
||||||
|
"string-to-arraybuffer": "^1.0.2",
|
||||||
|
"teeny-request": "3.7.0"
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"branches": [
|
||||||
|
"+([0-9]).x",
|
||||||
|
"main",
|
||||||
|
"next",
|
||||||
|
{
|
||||||
|
"name": "beta",
|
||||||
|
"prerelease": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
31
node_modules/proj4/.github/workflows/build-and-test.yml
generated
vendored
Normal file
31
node_modules/proj4/.github/workflows/build-and-test.yml
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
||||||
|
|
||||||
|
name: Node.js CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [14.x, 16.x, 18.x]
|
||||||
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build --if-present
|
||||||
|
- run: npm test
|
12
node_modules/proj4/.jshintrc
generated
vendored
Normal file
12
node_modules/proj4/.jshintrc
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"esversion": 6,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"latedef": "nofunc",
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"trailing": true,
|
||||||
|
"indent": 2,
|
||||||
|
"browser": true,
|
||||||
|
"node": true
|
||||||
|
}
|
25
node_modules/proj4/AUTHORS
generated
vendored
Normal file
25
node_modules/proj4/AUTHORS
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
Mike Adair <madair@dmsolutions.ca>
|
||||||
|
Richard Greenwood <rich@greenwoodmap.com>
|
||||||
|
Calvin Metcalf <calvin.metcalf@gmail.com>
|
||||||
|
Richard Marsden (http://www.winwaed.com)
|
||||||
|
#credit for
|
||||||
|
#src/projCode/gnom.js
|
||||||
|
#src/projCode/cea.js
|
||||||
|
T. Mittan
|
||||||
|
#credit for
|
||||||
|
#src/projCode/eqdc.js
|
||||||
|
#src/projCode/equi.js
|
||||||
|
#src/projCode/merc.js
|
||||||
|
#src/projCode/mill.js
|
||||||
|
#src/projCode/omerc.js
|
||||||
|
#src/projCode/ortho.js
|
||||||
|
#src/projCode/poly.js
|
||||||
|
#src/projCode/poly.js
|
||||||
|
D. Steinwand
|
||||||
|
#credit for
|
||||||
|
#src/projCode/merc.js
|
||||||
|
#src/projCode/laea.js
|
||||||
|
#src/projCode/moll.js
|
||||||
|
S. Nelson
|
||||||
|
#credit for
|
||||||
|
#src/projCode/moll.js
|
126
node_modules/proj4/Gruntfile.js
generated
vendored
Normal file
126
node_modules/proj4/Gruntfile.js
generated
vendored
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
var json = require('rollup-plugin-json');
|
||||||
|
var nodeResolve = require('rollup-plugin-node-resolve');
|
||||||
|
var replace = require('rollup-plugin-replace');
|
||||||
|
var pkg = require('./package.json');
|
||||||
|
|
||||||
|
var projs = [
|
||||||
|
'tmerc',
|
||||||
|
'etmerc',
|
||||||
|
'utm',
|
||||||
|
'sterea',
|
||||||
|
'stere',
|
||||||
|
'somerc',
|
||||||
|
'omerc',
|
||||||
|
'lcc',
|
||||||
|
'krovak',
|
||||||
|
'cass',
|
||||||
|
'laea',
|
||||||
|
'aea',
|
||||||
|
'gnom',
|
||||||
|
'cea',
|
||||||
|
'eqc',
|
||||||
|
'poly',
|
||||||
|
'nzmg',
|
||||||
|
'mill',
|
||||||
|
'sinu',
|
||||||
|
'moll',
|
||||||
|
'eqdc',
|
||||||
|
'vandg',
|
||||||
|
'aeqd',
|
||||||
|
'ortho',
|
||||||
|
'qsc',
|
||||||
|
'robin',
|
||||||
|
'geocent',
|
||||||
|
'tpers',
|
||||||
|
'geos'
|
||||||
|
];
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
grunt.initConfig({
|
||||||
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
|
connect: {
|
||||||
|
server: {
|
||||||
|
options: {
|
||||||
|
port: process.env.PORT || 8080,
|
||||||
|
base: '.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mocha_phantomjs: {
|
||||||
|
all: {
|
||||||
|
options: {
|
||||||
|
reporter: "dot",
|
||||||
|
urls: [ //my ide requries process.env.IP and PORT
|
||||||
|
"http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/amd.html",
|
||||||
|
"http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/opt.html"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
jshint: {
|
||||||
|
options: {
|
||||||
|
jshintrc: "./.jshintrc"
|
||||||
|
},
|
||||||
|
all: ['./lib/*.js', './lib/*/*.js']
|
||||||
|
},
|
||||||
|
rollup: {
|
||||||
|
options: {
|
||||||
|
format: "umd",
|
||||||
|
moduleName: "proj4",
|
||||||
|
plugins: [
|
||||||
|
replace({
|
||||||
|
__VERSION__: pkg.version
|
||||||
|
}),
|
||||||
|
json(),
|
||||||
|
nodeResolve()
|
||||||
|
]
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
dest: './dist/proj4-src.js',
|
||||||
|
src: './lib/index.js',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
uglify: {
|
||||||
|
options: {
|
||||||
|
report: 'gzip',
|
||||||
|
mangle:{
|
||||||
|
reserved: ['proj4','Projection','Point']
|
||||||
|
},
|
||||||
|
},
|
||||||
|
all: {
|
||||||
|
src: 'dist/proj4-src.js',
|
||||||
|
dest: 'dist/proj4.js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grunt.loadNpmTasks('grunt-rollup');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||||
|
grunt.loadNpmTasks('grunt-mocha-phantomjs');
|
||||||
|
grunt.registerTask('custom',function(){
|
||||||
|
grunt.task.run('rollup', 'uglify');
|
||||||
|
var projections = this.args;
|
||||||
|
if(projections[0]==='default'){
|
||||||
|
grunt.file.write('./projs.js','export default function(){}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(projections[0]==='all'){
|
||||||
|
projections = projs;
|
||||||
|
}
|
||||||
|
grunt.file.write('./projs.js',[
|
||||||
|
projections.map(function(proj) {
|
||||||
|
return "import " + proj + " from './lib/projections/" + proj + "';";
|
||||||
|
}).join("\n"),
|
||||||
|
"export default function(proj4){",
|
||||||
|
projections.map(function(proj) {
|
||||||
|
return " proj4.Proj.projections.add(" + proj + ");"
|
||||||
|
}).join("\n"),
|
||||||
|
"}"
|
||||||
|
].join("\n"));
|
||||||
|
});
|
||||||
|
grunt.registerTask('build',function(){
|
||||||
|
var args = this.args.length?this.args[0].split(','):['default'];
|
||||||
|
grunt.task.run('jshint', 'custom:'+args.join(':'));
|
||||||
|
});
|
||||||
|
grunt.registerTask('default', ['build:all', 'connect','mocha_phantomjs']);
|
||||||
|
};
|
29
node_modules/proj4/LICENSE.md
generated
vendored
Normal file
29
node_modules/proj4/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
## Proj4js -- Javascript reprojection library.
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
- Mike Adair madairATdmsolutions.ca
|
||||||
|
- Richard Greenwood richATgreenwoodmap.com
|
||||||
|
- Didier Richard didier.richardATign.fr
|
||||||
|
- Stephen Irons stephen.ironsATclear.net.nz
|
||||||
|
- Olivier Terral oterralATgmail.com
|
||||||
|
- Calvin Metcalf cmetcalfATappgeo.com
|
||||||
|
|
||||||
|
Copyright (c) 2014, Mike Adair, Richard Greenwood, Didier Richard, Stephen Irons, Olivier Terral and Calvin Metcalf
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE._
|
21
node_modules/proj4/PUBLISHING.md
generated
vendored
Normal file
21
node_modules/proj4/PUBLISHING.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Publishing
|
||||||
|
===
|
||||||
|
|
||||||
|
Make sure you have the latest from the main branch:
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
Use `tin` to update the version number in the `package.json`, `component.json` & `bower.json`.
|
||||||
|
|
||||||
|
tin -v x.y.z
|
||||||
|
|
||||||
|
Then run the publish script
|
||||||
|
|
||||||
|
./publish.sh
|
||||||
|
|
||||||
|
afterwards don't forget to update the versions to be a prerelease of the next version, so if you just published 1.1.1 then:
|
||||||
|
|
||||||
|
tin -v 1.1.2-alpha
|
||||||
|
git add package.json component.json bower.json
|
||||||
|
git commit -m 'update version to 1.1.2-alpha'
|
||||||
|
git push origin master
|
194
node_modules/proj4/README.md
generated
vendored
Normal file
194
node_modules/proj4/README.md
generated
vendored
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
# PROJ4JS [![Build Status](https://api.travis-ci.org/proj4js/proj4js.svg?branch=master)](https://travis-ci.org/proj4js/proj4js)
|
||||||
|
|
||||||
|
Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.
|
||||||
|
Originally a port of [PROJ](https://proj.org/) ([then known as PROJ.4](https://proj.org/faq.html#what-happened-to-proj-4)) and GCTCP C ([Archive](https://web.archive.org/web/20130523091752/http://edcftp.cr.usgs.gov/pub/software/gctpc/)) it is
|
||||||
|
a part of the [MetaCRS](https://trac.osgeo.org/metacrs/wiki) group of projects.
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
Depending on your preferences
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install proj4
|
||||||
|
bower install proj4
|
||||||
|
component install proj4js/proj4js
|
||||||
|
```
|
||||||
|
|
||||||
|
or just manually grab the file `proj4.js` from the [latest release](https://github.com/proj4js/proj4js/releases)'s `dist/` folder.
|
||||||
|
|
||||||
|
If you do not want to download anything, Proj4js is also hosted on [cdnjs](https://www.cdnjs.com/libraries/proj4js) for direct use in your browser applications.
|
||||||
|
|
||||||
|
## Using
|
||||||
|
|
||||||
|
The basic signature is:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4([fromProjection, ]toProjection[, coordinates])
|
||||||
|
```
|
||||||
|
|
||||||
|
Projections can be proj or wkt strings.
|
||||||
|
|
||||||
|
Coordinates may be an object of the form `{x:x,y:y}` or an array of the form `[x,y]`.
|
||||||
|
|
||||||
|
When all 3 arguments are given, the result is that the coordinates are transformed from projection1 to projection 2. And returned in the same format that they were given in.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var firstProjection = '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]]';
|
||||||
|
var secondProjection = "+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
|
||||||
|
//I'm not going to redefine those two in latter examples.
|
||||||
|
proj4(firstProjection,secondProjection,[-122.305887, 58.9465872]);
|
||||||
|
// [-2690575.447893817, 36622916.8071244564]
|
||||||
|
```
|
||||||
|
|
||||||
|
The library can also parse coordinates provided with an elevation and measure, again as an object of the form `{x:x,y:y,z:z,m:m}` or an array of the form `[x,y,z,m]`.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4(firstProjection,secondProjection,[-122.305887, 58.9465872,10]);
|
||||||
|
// [-2690575.447893817, 36622916.8071244564, 10]
|
||||||
|
```
|
||||||
|
|
||||||
|
If only 1 projection is given then it is assumed that it is being projected *from* WGS84 (fromProjection is WGS84).
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4(firstProjection,[-71,41]);
|
||||||
|
// [242075.00535055372, 750123.32090043]
|
||||||
|
```
|
||||||
|
|
||||||
|
If no coordinates are given an object with two methods is returned, its methods are `forward` which projects from the first projection to the second and `inverse` which projects from the second to the first.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4(firstProjection,secondProjection).forward([-122.305887, 58.9465872]);
|
||||||
|
// [-2690575.447893817, 36622916.8071244564]
|
||||||
|
proj4(secondProjection,firstProjection).inverse([-122.305887, 58.9465872]);
|
||||||
|
// [-2690575.447893817, 36622916.8071244564]
|
||||||
|
```
|
||||||
|
|
||||||
|
And as above if only one projection is given, it's assumed to be coming from wgs84:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4(firstProjection).forward([-71,41]);
|
||||||
|
// [242075.00535055372, 750123.32090043]
|
||||||
|
proj4(firstProjection).inverse([242075.00535055372, 750123.32090043]);
|
||||||
|
// [-71, 40.99999999999986]
|
||||||
|
```
|
||||||
|
Note: The generation of the floating point value `40.99999999999986` in this example represents the fact that some variance in precision is involved in any conversion between one coordinate reference system and another.
|
||||||
|
|
||||||
|
## Named Projections
|
||||||
|
|
||||||
|
If you prefer to define a projection as a string and reference it that way, you may use the proj4.defs method which can be called 2 ways, with a name and projection:
|
||||||
|
|
||||||
|
```js
|
||||||
|
proj4.defs('WGS84', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
|
||||||
|
```
|
||||||
|
|
||||||
|
or with an array
|
||||||
|
|
||||||
|
```js
|
||||||
|
proj4.defs([
|
||||||
|
[
|
||||||
|
'EPSG:4326',
|
||||||
|
'+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees'],
|
||||||
|
[
|
||||||
|
'EPSG:4269',
|
||||||
|
'+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
|
you can then do
|
||||||
|
|
||||||
|
```js
|
||||||
|
proj4('EPSG:4326');
|
||||||
|
```
|
||||||
|
|
||||||
|
instead of writing out the whole proj definition, by default proj4 has the following projections predefined:
|
||||||
|
|
||||||
|
- 'EPSG:4326', which has the following alias
|
||||||
|
- 'WGS84'
|
||||||
|
- 'EPSG:4269'
|
||||||
|
- 'EPSG:3857', which has the following aliases
|
||||||
|
- 'EPSG:3785'
|
||||||
|
- 'GOOGLE'
|
||||||
|
- 'EPSG:900913'
|
||||||
|
- 'EPSG:102113'
|
||||||
|
|
||||||
|
Defined projections can also be accessed through the proj4.defs function (`proj4.defs('EPSG:4326')`).
|
||||||
|
|
||||||
|
proj4.defs can also be used to define a named alias:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
|
||||||
|
```
|
||||||
|
|
||||||
|
## Axis order
|
||||||
|
|
||||||
|
By default, proj4 uses `[x,y]` axis order for projected (cartesian) coordinate systems and `[x=longitude,y=latitude]` for geographic coordinates. To enforce the axis order of the provided proj or wkt string, use the
|
||||||
|
```javascript
|
||||||
|
proj4(fromProjection, toProjection).forward(coordinate, enforceAxis);
|
||||||
|
proj4(fromProjection, toProjection).inverse(coordinate, enforceAxis);
|
||||||
|
```
|
||||||
|
signatures with `enforceAxis` set to `true`:
|
||||||
|
```javascript
|
||||||
|
proj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees +axis=neu', firstProjection).forward([41, -71], true);
|
||||||
|
// [242075.00535055372, 750123.32090043]
|
||||||
|
proj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees +axis=neu', firstProjection).inverse([242075.00535055372, 750123.32090043], true);
|
||||||
|
//[40.99999999999986, -71]
|
||||||
|
//the floating points to answer your question
|
||||||
|
```
|
||||||
|
|
||||||
|
## Grid Based Datum Adjustments
|
||||||
|
|
||||||
|
To use `+nadgrids=` in a proj definition, first read your NTv2 `.gsb` file (e.g. from https://github.com/OSGeo/proj-datumgrid) into an ArrayBuffer, then pass it to `proj4.nadgrid`. E.g:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const buffer = fs.readFileSync('ntv2.gsb').buffer
|
||||||
|
proj4.nadgrid('key', buffer);
|
||||||
|
```
|
||||||
|
|
||||||
|
then use the given key in your definition, e.g. `+nadgrids=@key,null`. See [Grid Based Datum Adjustments](https://proj.org/usage/transformation.html?highlight=nadgrids#grid-based-datum-adjustments).
|
||||||
|
|
||||||
|
## TypeScript
|
||||||
|
|
||||||
|
TypeScript implementation was added to the [DefinitelyTyped repository](https://github.com/DefinitelyTyped/DefinitelyTyped).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install --save @types/proj4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
To set up build tools make sure you have node and grunt-cli installed and then run `npm install`.
|
||||||
|
|
||||||
|
To do the complete build and browser tests run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node_modules/.bin/grunt
|
||||||
|
```
|
||||||
|
|
||||||
|
To run node tests run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
To run node tests with coverage run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test --coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a build with only default projections (latlon and Mercator) run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node_modules/.bin/grunt build
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a build with only custom projections include a comma separated list of projections codes (the file name in 'lib/projections' without the '.js') after a colon, e.g.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node_modules/.bin/grunt build:tmerc
|
||||||
|
#includes transverse Mercator
|
||||||
|
node_modules/.bin/grunt build:lcc
|
||||||
|
#includes lambert conformal conic
|
||||||
|
node_modules/.bin/grunt build:omerc,moll
|
||||||
|
#includes oblique Mercator and Mollweide
|
||||||
|
```
|
33
node_modules/proj4/REFERENCES.md
generated
vendored
Normal file
33
node_modules/proj4/REFERENCES.md
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological Survey
|
||||||
|
Professional Paper 1395 (Supersedes USGS Bulletin 1532),
|
||||||
|
United States Government Printing Office, Washington D.C., 1987.
|
||||||
|
Accessed: 2016-05-09. https://pubs.er.usgs.gov/publication/pp1395
|
||||||
|
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
|
||||||
|
U.S. Geological Survey Professional Paper 1453 ,
|
||||||
|
United State Government Printing Office, Washington D.C., 1989.
|
||||||
|
Accessed: 2016-05-09. https://pubs.er.usgs.gov/publication/pp1453
|
||||||
|
3. "Cartographic Projection Procedures for the UNIX Environment-
|
||||||
|
A User's Manual" by Gerald I. Evenden,
|
||||||
|
USGS Open File Report 90-284 and Release 4 Interim Reports (2003).
|
||||||
|
Accessed: 2016-06-09. http://www2.bren.ucsb.edu/~frew/ESM264/private/proj_manual.pdf
|
||||||
|
4. Snyder, John P., "Flattening the Earth -
|
||||||
|
Two Thousand Years of Map Projections", Univ. Chicago Press, 1993
|
||||||
|
5. Wolfram Mathworld "Gnomonic Projection"
|
||||||
|
http://mathworld.wolfram.com/GnomonicProjection.html
|
||||||
|
Accessed: 12th November 2009
|
||||||
|
6. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
|
||||||
|
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
|
||||||
|
7. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
|
||||||
|
Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
|
||||||
|
State Government Printing Office, Washington D.C., 1987.
|
||||||
|
Access date 2016-05-09. https://pubs.er.usgs.gov/publication/pp1395
|
||||||
|
8. "Software Documentation for GCTP General Cartographic Transformation
|
||||||
|
Package", U.S. Geological Survey National Mapping Division, May 1982.
|
||||||
|
9. Department of Land and Survey Technical Circular 1973/32
|
||||||
|
http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf
|
||||||
|
10. OSG Technical Report 4.1
|
||||||
|
http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf
|
||||||
|
11. Formules et constantes pour le Calcul pour la
|
||||||
|
projection cylindrique conforme à axe oblique et pour la transformation entre
|
||||||
|
des systèmes de référence.
|
||||||
|
http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
|
24
node_modules/proj4/bower.json
generated
vendored
Normal file
24
node_modules/proj4/bower.json
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "proj4",
|
||||||
|
"version": "2.9.0",
|
||||||
|
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
|
||||||
|
"homepage": "https://github.com/proj4js/proj4js",
|
||||||
|
"main": "dist/proj4.js",
|
||||||
|
"keywords": [
|
||||||
|
"gis",
|
||||||
|
"projections",
|
||||||
|
"geospatial",
|
||||||
|
"transform",
|
||||||
|
"datum"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests",
|
||||||
|
"almond",
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
}
|
21
node_modules/proj4/changelog.md
generated
vendored
Normal file
21
node_modules/proj4/changelog.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Change log
|
||||||
|
===
|
||||||
|
- 2.2.1: Documentation fixes and added proj4.defs('name') as an alias for proj4.defs['name'];
|
||||||
|
|
||||||
|
- 2.1.4: dist folder is added back in after accidentally omitting it in 2.1.1
|
||||||
|
|
||||||
|
- 2.1.3: skipped as issues with the dist folder are ironed out.
|
||||||
|
|
||||||
|
- 2.1.2: added sensible defaults for false eastings/northings
|
||||||
|
|
||||||
|
- 2.1.1: tweaks to how we publish it, fixes related to errors with the OSGB36 and Reseau National Belge 1972 datums, we took the first steps towards depreciating the proj4.Point class.
|
||||||
|
|
||||||
|
- 2.1.0: targeted builds for projections are now supported, and internally projection creation is more modular.
|
||||||
|
|
||||||
|
- 2.0.3: mgrs is broken out into it's own module loaded via npm.
|
||||||
|
|
||||||
|
- 2.0.2: module common is broken up into a collection of smaller modules.
|
||||||
|
|
||||||
|
- 2.0.1: fix typo in eqc projection.
|
||||||
|
|
||||||
|
- 2.0.0: we start the change log.
|
17
node_modules/proj4/component.json
generated
vendored
Normal file
17
node_modules/proj4/component.json
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "proj4",
|
||||||
|
"version": "2.9.0",
|
||||||
|
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
|
||||||
|
"repo": "proj4js/proj4js",
|
||||||
|
"keywords": [
|
||||||
|
"projections",
|
||||||
|
"proj4",
|
||||||
|
"transform",
|
||||||
|
"crs"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "dist/proj4.js",
|
||||||
|
"scripts": [
|
||||||
|
"dist/proj4.js"
|
||||||
|
]
|
||||||
|
}
|
7355
node_modules/proj4/dist/proj4-src.js
generated
vendored
Normal file
7355
node_modules/proj4/dist/proj4-src.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/proj4/dist/proj4.js
generated
vendored
Normal file
1
node_modules/proj4/dist/proj4.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
34
node_modules/proj4/lib/Point.js
generated
vendored
Normal file
34
node_modules/proj4/lib/Point.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import {toPoint, forward} from 'mgrs';
|
||||||
|
|
||||||
|
function Point(x, y, z) {
|
||||||
|
if (!(this instanceof Point)) {
|
||||||
|
return new Point(x, y, z);
|
||||||
|
}
|
||||||
|
if (Array.isArray(x)) {
|
||||||
|
this.x = x[0];
|
||||||
|
this.y = x[1];
|
||||||
|
this.z = x[2] || 0.0;
|
||||||
|
} else if(typeof x === 'object') {
|
||||||
|
this.x = x.x;
|
||||||
|
this.y = x.y;
|
||||||
|
this.z = x.z || 0.0;
|
||||||
|
} else if (typeof x === 'string' && typeof y === 'undefined') {
|
||||||
|
var coords = x.split(',');
|
||||||
|
this.x = parseFloat(coords[0], 10);
|
||||||
|
this.y = parseFloat(coords[1], 10);
|
||||||
|
this.z = parseFloat(coords[2], 10) || 0.0;
|
||||||
|
} else {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z || 0.0;
|
||||||
|
}
|
||||||
|
console.warn('proj4.Point will be removed in version 3, use proj4.toPoint');
|
||||||
|
}
|
||||||
|
|
||||||
|
Point.fromMGRS = function(mgrsStr) {
|
||||||
|
return new Point(toPoint(mgrsStr));
|
||||||
|
};
|
||||||
|
Point.prototype.toMGRS = function(accuracy) {
|
||||||
|
return forward([this.x, this.y], accuracy);
|
||||||
|
};
|
||||||
|
export default Point;
|
74
node_modules/proj4/lib/Proj.js
generated
vendored
Normal file
74
node_modules/proj4/lib/Proj.js
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import parseCode from './parseCode';
|
||||||
|
import extend from './extend';
|
||||||
|
import projections from './projections';
|
||||||
|
import {sphere as dc_sphere, eccentricity as dc_eccentricity} from './deriveConstants';
|
||||||
|
import Datum from './constants/Datum';
|
||||||
|
import datum from './datum';
|
||||||
|
import match from './match';
|
||||||
|
import {getNadgrids} from "./nadgrid";
|
||||||
|
|
||||||
|
function Projection(srsCode,callback) {
|
||||||
|
if (!(this instanceof Projection)) {
|
||||||
|
return new Projection(srsCode);
|
||||||
|
}
|
||||||
|
callback = callback || function(error){
|
||||||
|
if(error){
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var json = parseCode(srsCode);
|
||||||
|
if(typeof json !== 'object'){
|
||||||
|
callback(srsCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var ourProj = Projection.projections.get(json.projName);
|
||||||
|
if(!ourProj){
|
||||||
|
callback(srsCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (json.datumCode && json.datumCode !== 'none') {
|
||||||
|
var datumDef = match(Datum, json.datumCode);
|
||||||
|
if (datumDef) {
|
||||||
|
json.datum_params = json.datum_params || (datumDef.towgs84 ? datumDef.towgs84.split(',') : null);
|
||||||
|
json.ellps = datumDef.ellipse;
|
||||||
|
json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
json.k0 = json.k0 || 1.0;
|
||||||
|
json.axis = json.axis || 'enu';
|
||||||
|
json.ellps = json.ellps || 'wgs84';
|
||||||
|
json.lat1 = json.lat1 || json.lat0; // Lambert_Conformal_Conic_1SP, for example, needs this
|
||||||
|
|
||||||
|
var sphere_ = dc_sphere(json.a, json.b, json.rf, json.ellps, json.sphere);
|
||||||
|
var ecc = dc_eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A);
|
||||||
|
var nadgrids = getNadgrids(json.nadgrids);
|
||||||
|
var datumObj = json.datum || datum(json.datumCode, json.datum_params, sphere_.a, sphere_.b, ecc.es, ecc.ep2,
|
||||||
|
nadgrids);
|
||||||
|
|
||||||
|
extend(this, json); // transfer everything over from the projection because we don't know what we'll need
|
||||||
|
extend(this, ourProj); // transfer all the methods from the projection
|
||||||
|
|
||||||
|
// copy the 4 things over we calculated in deriveConstants.sphere
|
||||||
|
this.a = sphere_.a;
|
||||||
|
this.b = sphere_.b;
|
||||||
|
this.rf = sphere_.rf;
|
||||||
|
this.sphere = sphere_.sphere;
|
||||||
|
|
||||||
|
// copy the 3 things we calculated in deriveConstants.eccentricity
|
||||||
|
this.es = ecc.es;
|
||||||
|
this.e = ecc.e;
|
||||||
|
this.ep2 = ecc.ep2;
|
||||||
|
|
||||||
|
// add in the datum object
|
||||||
|
this.datum = datumObj;
|
||||||
|
|
||||||
|
// init the projection
|
||||||
|
this.init();
|
||||||
|
|
||||||
|
// legecy callback from back in the day when it went to spatialreference.org
|
||||||
|
callback(null, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
Projection.projections = projections;
|
||||||
|
Projection.projections.start();
|
||||||
|
export default Projection;
|
61
node_modules/proj4/lib/adjust_axis.js
generated
vendored
Normal file
61
node_modules/proj4/lib/adjust_axis.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
export default function(crs, denorm, point) {
|
||||||
|
var xin = point.x,
|
||||||
|
yin = point.y,
|
||||||
|
zin = point.z || 0.0;
|
||||||
|
var v, t, i;
|
||||||
|
var out = {};
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (denorm && i === 2 && point.z === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i === 0) {
|
||||||
|
v = xin;
|
||||||
|
if ("ew".indexOf(crs.axis[i]) !== -1) {
|
||||||
|
t = 'x';
|
||||||
|
} else {
|
||||||
|
t = 'y';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (i === 1) {
|
||||||
|
v = yin;
|
||||||
|
if ("ns".indexOf(crs.axis[i]) !== -1) {
|
||||||
|
t = 'y';
|
||||||
|
} else {
|
||||||
|
t = 'x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
v = zin;
|
||||||
|
t = 'z';
|
||||||
|
}
|
||||||
|
switch (crs.axis[i]) {
|
||||||
|
case 'e':
|
||||||
|
out[t] = v;
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
out[t] = -v;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
out[t] = v;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
out[t] = -v;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
if (point[t] !== undefined) {
|
||||||
|
out.z = v;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
if (point[t] !== undefined) {
|
||||||
|
out.z = -v;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//console.log("ERROR: unknow axis ("+crs.axis[i]+") - check definition of "+crs.projName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
15
node_modules/proj4/lib/checkSanity.js
generated
vendored
Normal file
15
node_modules/proj4/lib/checkSanity.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
export default function (point) {
|
||||||
|
checkCoord(point.x);
|
||||||
|
checkCoord(point.y);
|
||||||
|
}
|
||||||
|
function checkCoord(num) {
|
||||||
|
if (typeof Number.isFinite === 'function') {
|
||||||
|
if (Number.isFinite(num)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new TypeError('coordinates must be finite numbers');
|
||||||
|
}
|
||||||
|
if (typeof num !== 'number' || num !== num || !isFinite(num)) {
|
||||||
|
throw new TypeError('coordinates must be finite numbers');
|
||||||
|
}
|
||||||
|
}
|
3
node_modules/proj4/lib/common/acosh.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/acosh.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return 2 * Math.log(Math.sqrt((x + 1) / 2) + Math.sqrt((x - 1) / 2));
|
||||||
|
}
|
6
node_modules/proj4/lib/common/adjust_lat.js
generated
vendored
Normal file
6
node_modules/proj4/lib/common/adjust_lat.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import {HALF_PI} from '../constants/values';
|
||||||
|
import sign from './sign';
|
||||||
|
|
||||||
|
export default function(x) {
|
||||||
|
return (Math.abs(x) < HALF_PI) ? x : (x - (sign(x) * Math.PI));
|
||||||
|
}
|
7
node_modules/proj4/lib/common/adjust_lon.js
generated
vendored
Normal file
7
node_modules/proj4/lib/common/adjust_lon.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
import {TWO_PI, SPI} from '../constants/values';
|
||||||
|
import sign from './sign';
|
||||||
|
|
||||||
|
export default function(x) {
|
||||||
|
return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));
|
||||||
|
}
|
14
node_modules/proj4/lib/common/adjust_zone.js
generated
vendored
Normal file
14
node_modules/proj4/lib/common/adjust_zone.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import adjust_lon from './adjust_lon';
|
||||||
|
|
||||||
|
export default function(zone, lon) {
|
||||||
|
if (zone === undefined) {
|
||||||
|
zone = Math.floor((adjust_lon(lon) + Math.PI) * 30 / Math.PI) + 1;
|
||||||
|
|
||||||
|
if (zone < 0) {
|
||||||
|
return 0;
|
||||||
|
} else if (zone > 60) {
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zone;
|
||||||
|
}
|
4
node_modules/proj4/lib/common/asinh.js
generated
vendored
Normal file
4
node_modules/proj4/lib/common/asinh.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export default function(x) {
|
||||||
|
var s = (x >= 0 ? 1 : -1);
|
||||||
|
return s * (Math.log(Math.abs(x) + Math.sqrt(x * x + 1)));
|
||||||
|
}
|
9
node_modules/proj4/lib/common/asinhy.js
generated
vendored
Normal file
9
node_modules/proj4/lib/common/asinhy.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import hypot from './hypot';
|
||||||
|
import log1py from './log1py';
|
||||||
|
|
||||||
|
export default function(x) {
|
||||||
|
var y = Math.abs(x);
|
||||||
|
y = log1py(y * (1 + y / (hypot(1, y) + 1)));
|
||||||
|
|
||||||
|
return x < 0 ? -y : y;
|
||||||
|
}
|
6
node_modules/proj4/lib/common/asinz.js
generated
vendored
Normal file
6
node_modules/proj4/lib/common/asinz.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export default function(x) {
|
||||||
|
if (Math.abs(x) > 1) {
|
||||||
|
x = (x > 1) ? 1 : -1;
|
||||||
|
}
|
||||||
|
return Math.asin(x);
|
||||||
|
}
|
3
node_modules/proj4/lib/common/atanh.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/atanh.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return Math.log((x - 1) / (x + 1)) / 2;
|
||||||
|
}
|
15
node_modules/proj4/lib/common/clens.js
generated
vendored
Normal file
15
node_modules/proj4/lib/common/clens.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
export default function(pp, arg_r) {
|
||||||
|
var r = 2 * Math.cos(arg_r);
|
||||||
|
var i = pp.length - 1;
|
||||||
|
var hr1 = pp[i];
|
||||||
|
var hr2 = 0;
|
||||||
|
var hr;
|
||||||
|
|
||||||
|
while (--i >= 0) {
|
||||||
|
hr = -hr2 + r * hr1 + pp[i];
|
||||||
|
hr2 = hr1;
|
||||||
|
hr1 = hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.sin(arg_r) * hr;
|
||||||
|
}
|
32
node_modules/proj4/lib/common/clens_cmplx.js
generated
vendored
Normal file
32
node_modules/proj4/lib/common/clens_cmplx.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import sinh from './sinh';
|
||||||
|
import cosh from './cosh';
|
||||||
|
|
||||||
|
export default function(pp, arg_r, arg_i) {
|
||||||
|
var sin_arg_r = Math.sin(arg_r);
|
||||||
|
var cos_arg_r = Math.cos(arg_r);
|
||||||
|
var sinh_arg_i = sinh(arg_i);
|
||||||
|
var cosh_arg_i = cosh(arg_i);
|
||||||
|
var r = 2 * cos_arg_r * cosh_arg_i;
|
||||||
|
var i = -2 * sin_arg_r * sinh_arg_i;
|
||||||
|
var j = pp.length - 1;
|
||||||
|
var hr = pp[j];
|
||||||
|
var hi1 = 0;
|
||||||
|
var hr1 = 0;
|
||||||
|
var hi = 0;
|
||||||
|
var hr2;
|
||||||
|
var hi2;
|
||||||
|
|
||||||
|
while (--j >= 0) {
|
||||||
|
hr2 = hr1;
|
||||||
|
hi2 = hi1;
|
||||||
|
hr1 = hr;
|
||||||
|
hi1 = hi;
|
||||||
|
hr = -hr2 + r * hr1 - i * hi1 + pp[j];
|
||||||
|
hi = -hi2 + i * hr1 + r * hi1;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sin_arg_r * cosh_arg_i;
|
||||||
|
i = cos_arg_r * sinh_arg_i;
|
||||||
|
|
||||||
|
return [r * hr - i * hi, r * hi + i * hr];
|
||||||
|
}
|
5
node_modules/proj4/lib/common/cosh.js
generated
vendored
Normal file
5
node_modules/proj4/lib/common/cosh.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export default function(x) {
|
||||||
|
var r = Math.exp(x);
|
||||||
|
r = (r + 1 / r) / 2;
|
||||||
|
return r;
|
||||||
|
}
|
3
node_modules/proj4/lib/common/e0fn.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/e0fn.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return (1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x)));
|
||||||
|
}
|
3
node_modules/proj4/lib/common/e1fn.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/e1fn.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return (0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x)));
|
||||||
|
}
|
3
node_modules/proj4/lib/common/e2fn.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/e2fn.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return (0.05859375 * x * x * (1 + 0.75 * x));
|
||||||
|
}
|
3
node_modules/proj4/lib/common/e3fn.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/e3fn.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(x) {
|
||||||
|
return (x * x * x * (35 / 3072));
|
||||||
|
}
|
5
node_modules/proj4/lib/common/fL.js
generated
vendored
Normal file
5
node_modules/proj4/lib/common/fL.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import {HALF_PI} from '../constants/values';
|
||||||
|
|
||||||
|
export default function(x, L) {
|
||||||
|
return 2 * Math.atan(x * Math.exp(L)) - HALF_PI;
|
||||||
|
}
|
4
node_modules/proj4/lib/common/gN.js
generated
vendored
Normal file
4
node_modules/proj4/lib/common/gN.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export default function(a, e, sinphi) {
|
||||||
|
var temp = e * sinphi;
|
||||||
|
return a / Math.sqrt(1 - temp * temp);
|
||||||
|
}
|
15
node_modules/proj4/lib/common/gatg.js
generated
vendored
Normal file
15
node_modules/proj4/lib/common/gatg.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
export default function(pp, B) {
|
||||||
|
var cos_2B = 2 * Math.cos(2 * B);
|
||||||
|
var i = pp.length - 1;
|
||||||
|
var h1 = pp[i];
|
||||||
|
var h2 = 0;
|
||||||
|
var h;
|
||||||
|
|
||||||
|
while (--i >= 0) {
|
||||||
|
h = -h2 + cos_2B * h1 + pp[i];
|
||||||
|
h2 = h1;
|
||||||
|
h1 = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B + h * Math.sin(2 * B));
|
||||||
|
}
|
8
node_modules/proj4/lib/common/hypot.js
generated
vendored
Normal file
8
node_modules/proj4/lib/common/hypot.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
export default function(x, y) {
|
||||||
|
x = Math.abs(x);
|
||||||
|
y = Math.abs(y);
|
||||||
|
var a = Math.max(x, y);
|
||||||
|
var b = Math.min(x, y) / (a ? a : 1);
|
||||||
|
|
||||||
|
return a * Math.sqrt(1 + Math.pow(b, 2));
|
||||||
|
}
|
16
node_modules/proj4/lib/common/imlfn.js
generated
vendored
Normal file
16
node_modules/proj4/lib/common/imlfn.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
export default function(ml, e0, e1, e2, e3) {
|
||||||
|
var phi;
|
||||||
|
var dphi;
|
||||||
|
|
||||||
|
phi = ml / e0;
|
||||||
|
for (var i = 0; i < 15; i++) {
|
||||||
|
dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));
|
||||||
|
phi += dphi;
|
||||||
|
if (Math.abs(dphi) <= 0.0000000001) {
|
||||||
|
return phi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//..reportError("IMLFN-CONV:Latitude failed to converge after 15 iterations");
|
||||||
|
return NaN;
|
||||||
|
}
|
13
node_modules/proj4/lib/common/invlatiso.js
generated
vendored
Normal file
13
node_modules/proj4/lib/common/invlatiso.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import fL from './fL';
|
||||||
|
|
||||||
|
export default function(eccent, ts) {
|
||||||
|
var phi = fL(1, ts);
|
||||||
|
var Iphi = 0;
|
||||||
|
var con = 0;
|
||||||
|
do {
|
||||||
|
Iphi = phi;
|
||||||
|
con = eccent * Math.sin(Iphi);
|
||||||
|
phi = fL(Math.exp(eccent * Math.log((1 + con) / (1 - con)) / 2), ts);
|
||||||
|
} while (Math.abs(phi - Iphi) > 1.0e-12);
|
||||||
|
return phi;
|
||||||
|
}
|
32
node_modules/proj4/lib/common/iqsfnz.js
generated
vendored
Normal file
32
node_modules/proj4/lib/common/iqsfnz.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import {HALF_PI} from '../constants/values';
|
||||||
|
|
||||||
|
export default function(eccent, q) {
|
||||||
|
var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));
|
||||||
|
if (Math.abs(Math.abs(q) - temp) < 1.0E-6) {
|
||||||
|
if (q < 0) {
|
||||||
|
return (-1 * HALF_PI);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return HALF_PI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//var phi = 0.5* q/(1-eccent*eccent);
|
||||||
|
var phi = Math.asin(0.5 * q);
|
||||||
|
var dphi;
|
||||||
|
var sin_phi;
|
||||||
|
var cos_phi;
|
||||||
|
var con;
|
||||||
|
for (var i = 0; i < 30; i++) {
|
||||||
|
sin_phi = Math.sin(phi);
|
||||||
|
cos_phi = Math.cos(phi);
|
||||||
|
con = eccent * sin_phi;
|
||||||
|
dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
|
||||||
|
phi += dphi;
|
||||||
|
if (Math.abs(dphi) <= 0.0000000001) {
|
||||||
|
return phi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log("IQSFN-CONV:Latitude failed to converge after 30 iterations");
|
||||||
|
return NaN;
|
||||||
|
}
|
16
node_modules/proj4/lib/common/latiso.js
generated
vendored
Normal file
16
node_modules/proj4/lib/common/latiso.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import {HALF_PI} from '../constants/values';
|
||||||
|
|
||||||
|
export default function(eccent, phi, sinphi) {
|
||||||
|
if (Math.abs(phi) > HALF_PI) {
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
if (phi === HALF_PI) {
|
||||||
|
return Number.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
if (phi === -1 * HALF_PI) {
|
||||||
|
return Number.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
var con = eccent * sinphi;
|
||||||
|
return Math.log(Math.tan((HALF_PI + phi) / 2)) + eccent * Math.log((1 - con) / (1 + con)) / 2;
|
||||||
|
}
|
6
node_modules/proj4/lib/common/log1py.js
generated
vendored
Normal file
6
node_modules/proj4/lib/common/log1py.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export default function(x) {
|
||||||
|
var y = 1 + x;
|
||||||
|
var z = y - 1;
|
||||||
|
|
||||||
|
return z === 0 ? x : x * Math.log(y) / z;
|
||||||
|
}
|
3
node_modules/proj4/lib/common/mlfn.js
generated
vendored
Normal file
3
node_modules/proj4/lib/common/mlfn.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function(e0, e1, e2, e3, phi) {
|
||||||
|
return (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi));
|
||||||
|
}
|
4
node_modules/proj4/lib/common/msfnz.js
generated
vendored
Normal file
4
node_modules/proj4/lib/common/msfnz.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export default function(eccent, sinphi, cosphi) {
|
||||||
|
var con = eccent * sinphi;
|
||||||
|
return cosphi / (Math.sqrt(1 - con * con));
|
||||||
|
}
|
17
node_modules/proj4/lib/common/phi2z.js
generated
vendored
Normal file
17
node_modules/proj4/lib/common/phi2z.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {HALF_PI} from '../constants/values';
|
||||||
|
|
||||||
|
export default function(eccent, ts) {
|
||||||
|
var eccnth = 0.5 * eccent;
|
||||||
|
var con, dphi;
|
||||||
|
var phi = HALF_PI - 2 * Math.atan(ts);
|
||||||
|
for (var i = 0; i <= 15; i++) {
|
||||||
|
con = eccent * Math.sin(phi);
|
||||||
|
dphi = HALF_PI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi;
|
||||||
|
phi += dphi;
|
||||||
|
if (Math.abs(dphi) <= 0.0000000001) {
|
||||||
|
return phi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log("phi2z has NoConvergence");
|
||||||
|
return -9999;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user