proj4 2.15.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.github/workflows/build-and-test.yml +45 -7
  2. package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
  3. package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
  4. package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
  5. package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
  6. package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
  7. package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
  8. package/.nyc_output/processinfo/index.json +1 -0
  9. package/Gruntfile.js +20 -84
  10. package/README.md +20 -6
  11. package/bower.json +1 -1
  12. package/component.json +1 -1
  13. package/dist/proj4-src.js +8934 -7083
  14. package/dist/proj4.js +1 -1
  15. package/eslint.config.mjs +41 -0
  16. package/lib/Point.js +4 -4
  17. package/lib/Proj.js +7 -8
  18. package/lib/adjust_axis.js +30 -33
  19. package/lib/common/acosh.js +2 -2
  20. package/lib/common/adjust_lat.js +2 -2
  21. package/lib/common/adjust_lon.js +2 -3
  22. package/lib/common/adjust_zone.js +1 -1
  23. package/lib/common/asinh.js +2 -2
  24. package/lib/common/asinhy.js +1 -1
  25. package/lib/common/asinz.js +2 -2
  26. package/lib/common/atanh.js +2 -2
  27. package/lib/common/clens.js +1 -1
  28. package/lib/common/clens_cmplx.js +1 -1
  29. package/lib/common/cosh.js +2 -2
  30. package/lib/common/e0fn.js +2 -2
  31. package/lib/common/e1fn.js +2 -2
  32. package/lib/common/e2fn.js +2 -2
  33. package/lib/common/e3fn.js +2 -2
  34. package/lib/common/fL.js +2 -2
  35. package/lib/common/gN.js +2 -2
  36. package/lib/common/gatg.js +1 -1
  37. package/lib/common/hypot.js +1 -1
  38. package/lib/common/imlfn.js +3 -3
  39. package/lib/common/invlatiso.js +2 -2
  40. package/lib/common/iqsfnz.js +5 -6
  41. package/lib/common/latiso.js +2 -2
  42. package/lib/common/log1py.js +1 -1
  43. package/lib/common/mlfn.js +2 -2
  44. package/lib/common/msfnz.js +2 -2
  45. package/lib/common/phi2z.js +3 -3
  46. package/lib/common/pj_enfn.js +2 -2
  47. package/lib/common/pj_inv_mlfn.js +6 -6
  48. package/lib/common/pj_mlfn.js +2 -2
  49. package/lib/common/qsfnz.js +3 -4
  50. package/lib/common/sign.js +3 -3
  51. package/lib/common/sinh.js +2 -2
  52. package/lib/common/srat.js +2 -2
  53. package/lib/common/tanh.js +2 -2
  54. package/lib/common/toPoint.js +4 -4
  55. package/lib/common/tsfnz.js +2 -2
  56. package/lib/constants/Datum.js +1228 -46
  57. package/lib/constants/Ellipsoid.js +225 -266
  58. package/lib/constants/PrimeMeridian.js +14 -14
  59. package/lib/constants/units.js +20 -20
  60. package/lib/constants/values.js +4 -4
  61. package/lib/core.js +2 -2
  62. package/lib/datum.js +2 -2
  63. package/lib/datumUtils.js +9 -14
  64. package/lib/datum_transform.js +26 -26
  65. package/lib/defs.js +10 -20
  66. package/lib/deriveConstants.js +4 -2
  67. package/lib/extend.js +1 -1
  68. package/lib/global.js +6 -6
  69. package/lib/includedProjections.js +25 -25
  70. package/lib/index.js +9 -9
  71. package/lib/nadgrid.js +36 -14
  72. package/lib/parseCode.js +10 -11
  73. package/lib/projString.js +41 -44
  74. package/lib/projections/aea.js +7 -12
  75. package/lib/projections/aeqd.js +51 -86
  76. package/lib/projections/bonne.js +11 -13
  77. package/lib/projections/cass.js +8 -15
  78. package/lib/projections/cea.js +7 -9
  79. package/lib/projections/eqc.js +2 -5
  80. package/lib/projections/eqdc.js +10 -16
  81. package/lib/projections/eqearth.js +17 -17
  82. package/lib/projections/equi.js +4 -6
  83. package/lib/projections/etmerc.js +9 -11
  84. package/lib/projections/gauss.js +3 -3
  85. package/lib/projections/geocent.js +13 -14
  86. package/lib/projections/geos.js +136 -137
  87. package/lib/projections/gnom.js +8 -13
  88. package/lib/projections/gstmerc.js +2 -5
  89. package/lib/projections/krovak.js +3 -3
  90. package/lib/projections/laea.js +85 -97
  91. package/lib/projections/lcc.js +28 -33
  92. package/lib/projections/longlat.js +4 -4
  93. package/lib/projections/merc.js +12 -19
  94. package/lib/projections/mill.js +6 -7
  95. package/lib/projections/moll.js +8 -9
  96. package/lib/projections/nzmg.js +2 -2
  97. package/lib/projections/omerc.js +55 -57
  98. package/lib/projections/ortho.js +9 -10
  99. package/lib/projections/poly.js +13 -21
  100. package/lib/projections/qsc.js +19 -21
  101. package/lib/projections/robin.js +118 -118
  102. package/lib/projections/sinu.js +12 -23
  103. package/lib/projections/somerc.js +3 -3
  104. package/lib/projections/stere.js +29 -41
  105. package/lib/projections/sterea.js +3 -4
  106. package/lib/projections/tmerc.js +29 -36
  107. package/lib/projections/tpers.js +14 -15
  108. package/lib/projections/utm.js +3 -4
  109. package/lib/projections/vandg.js +15 -21
  110. package/lib/projections.js +12 -4
  111. package/lib/transform.js +3 -3
  112. package/package.json +29 -22
  113. package/projs.js +2 -2
  114. package/publish.sh +2 -2
  115. package/rollup.config.mjs +29 -0
  116. package/scripts/readme.md +10 -0
  117. package/scripts/updateDatums.mjs +119 -0
  118. package/scripts/updateEllipsoids.mjs +70 -0
  119. package/test/ntv2_0_downsampled_no_error_columns.gsb +0 -0
  120. package/test/opt.html +27 -24
  121. package/test/puppeteer-tests.mjs +110 -0
  122. package/test/test-ci.mjs +10 -0
  123. package/test/test.js +197 -125
  124. package/test/testData.js +1802 -312
  125. package/.jshintrc +0 -12
  126. package/test/amd.html +0 -63
  127. package/test/package.json.js +0 -1
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":90528,"argv":["/Users/ahocevar/.nvm/versions/node/v22.13.0/bin/node","/Users/ahocevar/.nvm/versions/node/v22.13.0/bin/npm","run","test:ci"],"execArgv":[],"cwd":"/Users/ahocevar/projects/proj4js","time":1739305208087,"ppid":90520,"coverageFilename":"/Users/ahocevar/projects/proj4js/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json","externalId":"","uuid":"6b047fc9-1bf2-4565-9e8a-9c0defc09dd7","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":"f4b0e40f-04ca-4b6d-bfeb-51d617db9841","pid":90576,"argv":["/Users/ahocevar/.nvm/versions/node/v22.13.0/bin/node","/Users/ahocevar/projects/proj4js/node_modules/.bin/mocha","test/test-ci.mjs"],"execArgv":[],"cwd":"/Users/ahocevar/projects/proj4js","time":1739305208556,"ppid":90549,"coverageFilename":"/Users/ahocevar/projects/proj4js/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json","externalId":"","uuid":"e2c5d0cc-9478-4f26-ad2f-de246d4c35de","files":["/Users/ahocevar/projects/proj4js/dist/proj4-src.js"]}
@@ -0,0 +1 @@
1
+ {"parent":"6b047fc9-1bf2-4565-9e8a-9c0defc09dd7","pid":90549,"argv":["/Users/ahocevar/.nvm/versions/node/v22.13.0/bin/node","/Users/ahocevar/.nvm/versions/node/v22.13.0/lib/node_modules/npm/bin/npm-cli.js","exec","--yes","--","mocha","test/test-ci.mjs"],"execArgv":[],"cwd":"/Users/ahocevar/projects/proj4js","time":1739305208222,"ppid":90528,"coverageFilename":"/Users/ahocevar/projects/proj4js/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json","externalId":"","uuid":"f4b0e40f-04ca-4b6d-bfeb-51d617db9841","files":[]}
@@ -0,0 +1 @@
1
+ {"processes":{"6b047fc9-1bf2-4565-9e8a-9c0defc09dd7":{"parent":null,"children":["f4b0e40f-04ca-4b6d-bfeb-51d617db9841"]},"e2c5d0cc-9478-4f26-ad2f-de246d4c35de":{"parent":"f4b0e40f-04ca-4b6d-bfeb-51d617db9841","children":[]},"f4b0e40f-04ca-4b6d-bfeb-51d617db9841":{"parent":"6b047fc9-1bf2-4565-9e8a-9c0defc09dd7","children":["e2c5d0cc-9478-4f26-ad2f-de246d4c35de"]}},"files":{"/Users/ahocevar/projects/proj4js/dist/proj4-src.js":["e2c5d0cc-9478-4f26-ad2f-de246d4c35de"]},"externalIds":{}}
package/Gruntfile.js CHANGED
@@ -1,8 +1,3 @@
1
- var json = require('rollup-plugin-json');
2
- var nodeResolve = require('rollup-plugin-node-resolve');
3
- var replace = require('rollup-plugin-replace');
4
- var pkg = require('./package.json');
5
-
6
1
  var projs = [
7
2
  'tmerc',
8
3
  'etmerc',
@@ -38,91 +33,32 @@ var projs = [
38
33
  ];
39
34
  module.exports = function (grunt) {
40
35
  grunt.initConfig({
41
- pkg: grunt.file.readJSON('package.json'),
42
- connect: {
43
- server: {
44
- options: {
45
- port: process.env.PORT || 8080,
46
- base: '.'
47
- }
48
- }
49
- },
50
- mocha_phantomjs: {
51
- all: {
52
- options: {
53
- reporter: "dot",
54
- urls: [ //my ide requries process.env.IP and PORT
55
- "http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/amd.html",
56
- "http://" + (process.env.IP || "127.0.0.1") + ":" + (process.env.PORT || "8080") + "/test/opt.html"
57
- ]
58
- }
59
- }
60
- },
61
- jshint: {
62
- options: {
63
- jshintrc: "./.jshintrc"
64
- },
65
- all: ['./lib/*.js', './lib/*/*.js']
66
- },
67
- rollup: {
68
- options: {
69
- format: "umd",
70
- moduleName: "proj4",
71
- plugins: [
72
- replace({
73
- __VERSION__: pkg.version
74
- }),
75
- json(),
76
- nodeResolve()
77
- ]
78
- },
79
- files: {
80
- dest: './dist/proj4-src.js',
81
- src: './lib/index.js',
82
- },
83
- },
84
- uglify: {
85
- options: {
86
- report: 'gzip',
87
- mangle:{
88
- reserved: ['proj4','Projection','Point']
89
- },
90
- },
91
- all: {
92
- src: 'dist/proj4-src.js',
93
- dest: 'dist/proj4.js'
94
- }
95
- }
36
+ pkg: grunt.file.readJSON('package.json')
96
37
  });
97
- grunt.loadNpmTasks('grunt-rollup');
98
- grunt.loadNpmTasks('grunt-contrib-uglify');
99
- grunt.loadNpmTasks('grunt-contrib-jshint');
100
- grunt.loadNpmTasks('grunt-contrib-connect');
101
- grunt.loadNpmTasks('grunt-mocha-phantomjs');
102
- grunt.registerTask('custom',function(){
103
- grunt.task.run('rollup', 'uglify');
38
+
39
+ grunt.registerTask('custom', function () {
104
40
  var projections = this.args;
105
- if(projections[0]==='default'){
106
- grunt.file.write('./projs.js','export default function(){}');
41
+ if (projections[0] === 'default') {
42
+ grunt.file.write('./projs.js', 'export default function(){}');
107
43
  return;
108
44
  }
109
- if(projections[0]==='all'){
45
+ if (projections[0] === 'all') {
110
46
  projections = projs;
111
47
  }
112
- grunt.file.write('./projs.js',[
113
- projections.map(function(proj) {
114
- return "import " + proj + " from './lib/projections/" + proj + "';";
115
- }).join("\n"),
116
- "export default function(proj4){",
117
- projections.map(function(proj) {
118
- return " proj4.Proj.projections.add(" + proj + ");"
119
- }).join("\n"),
120
- "}"
121
- ].join("\n"));
48
+ grunt.file.write('./projs.js', [
49
+ projections.map(function (proj) {
50
+ return 'import ' + proj + ' from \'./lib/projections/' + proj + '\';';
51
+ }).join('\n'),
52
+ 'export default function (proj4) {',
53
+ projections.map(function (proj) {
54
+ return ' proj4.Proj.projections.add(' + proj + ');';
55
+ }).join('\n'),
56
+ '}', ''
57
+ ].join('\n'));
122
58
  });
123
- grunt.registerTask('build',function(){
124
- var args = this.args.length?this.args[0].split(','):['default'];
125
- grunt.task.run('jshint', 'custom:'+args.join(':'));
59
+ grunt.registerTask('build', function () {
60
+ var args = this.args.length ? this.args[0].split(',') : ['default'];
61
+ grunt.task.run('custom:' + args.join(':'));
126
62
  });
127
- grunt.registerTask('default', ['build:all', 'connect','mocha_phantomjs']);
63
+ grunt.registerTask('default', ['build:all']);
128
64
  };
package/README.md CHANGED
@@ -26,9 +26,7 @@ The basic signature is:
26
26
  proj4([fromProjection, ]toProjection[, coordinates])
27
27
  ```
28
28
 
29
- Projections can be proj or wkt strings.
30
-
31
- Wkt strings must be in form of [version 1](https://docs.ogc.org/is/18-010r7/18-010r7.html#196) (earlier than 2015). Have a look at the [wkt-parser](https://github.com/proj4js/wkt-parser) for more info, or use proj strings instead.
29
+ Projections can be proj or wkt strings, or PROJJSON objects.
32
30
 
33
31
  Coordinates may be an object of the form `{x:x,y:y}` or an array of the form `[x,y]`.
34
32
 
@@ -140,9 +138,15 @@ proj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees +axis=neu', firstP
140
138
  //the floating points to answer your question
141
139
  ```
142
140
 
141
+ ## Datum Transformations
142
+
143
+ Proj4js has built-in Helmert transformations for many datums to transform to and from WGS84, which is used as pivot for datum transformations. If a datum is not available or not accurate enough for the desired region, custom Helmert transformations or grid based datum adjustments are supported.
144
+
145
+ WKT1 definitions can contain a `TOWGS84` parameter. For proj strings, `towgs84` or `nadgrids` can be specified. When using WKT2 or PROJJSON definitions, if a `BOUNDCRS` with an `ABRIDGEDTRANDFORMATION` to WGS84 is provided, Helmert transformation parameters (like `+towgs84=` in proj strings) or the name of the parameter file (like `+nadgrids=` in proj strings) will be extracted from it.
146
+
143
147
  ## Grid Based Datum Adjustments
144
148
 
145
- 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:
149
+ To use `+nadgrids=` in a proj definition or a WKT2/PROJJSON `ABRIDGEDTRANSFORM` with an `NTv2` method, 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:
146
150
 
147
151
  ```javascript
148
152
  const buffer = fs.readFileSync('ntv2.gsb').buffer
@@ -151,6 +155,15 @@ proj4.nadgrid('key', buffer);
151
155
 
152
156
  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).
153
157
 
158
+ Optionally, if your `.gsb` file does not contain latitude and longitude error columns, you can provide an `options` object argument to the `proj4.nadgrid` call, setting the `includeErrorFields` property to `false`, e.g:
159
+
160
+ ```javascript
161
+ const buffer = fs.readFileSync('ntv2.gsb').buffer
162
+ proj4.nadgrid('key', buffer, {includeErrorFields:false});
163
+ ```
164
+
165
+ If the options argument is omitted, `includeErrorFields` is assumed to be true.
166
+
154
167
  ## TypeScript
155
168
 
156
169
  TypeScript implementation was added to the [DefinitelyTyped repository](https://github.com/DefinitelyTyped/DefinitelyTyped).
@@ -168,7 +181,7 @@ To do the complete build and browser tests run
168
181
  node_modules/.bin/grunt
169
182
  ```
170
183
 
171
- To run node tests run
184
+ To run node and browser tests run
172
185
 
173
186
  ```bash
174
187
  npm test
@@ -177,7 +190,8 @@ npm test
177
190
  To run node tests with coverage run
178
191
 
179
192
  ```bash
180
- npm test --coverage
193
+ npm run build
194
+ npm run test:coverage
181
195
  ```
182
196
 
183
197
  To create a build with only default projections (latlon and Mercator) run
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proj4",
3
- "version": "2.15.0",
3
+ "version": "2.16.1",
4
4
  "description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
5
5
  "homepage": "https://github.com/proj4js/proj4js",
6
6
  "main": "dist/proj4.js",
package/component.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proj4",
3
- "version": "2.15.0",
3
+ "version": "2.16.1",
4
4
  "description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
5
5
  "repo": "proj4js/proj4js",
6
6
  "keywords": [