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,70 @@
1
+ import sqlite3 from 'sqlite3';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import datums from '../lib/constants/Datum.js'; // Import datums directly
5
+ import ellipsoids from '../lib/constants/Ellipsoid.js'; // Import ellipsoids directly
6
+ import { fileURLToPath } from 'url';
7
+
8
+ // Get the current file's directory
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ // Extract ellipsoid keys and ellipseName values from Ellipsoid.js
13
+ const ellipsoidKeys = Object.keys(ellipsoids);
14
+ const ellipsoidNames = Object.values(ellipsoids).map(ellipsoid => ellipsoid.ellipseName);
15
+
16
+ // Combine ellipsoid keys and ellipseName values into a single set
17
+ const ellipsoidSet = new Set([...ellipsoidKeys, ...ellipsoidNames]);
18
+
19
+ // Extract ellipse values from Datum.js
20
+ const datumEllipses = new Set(Object.values(datums).map(datum => datum.ellipse));
21
+
22
+ // Find missing ellipses
23
+ const missingEllipses = [...datumEllipses].filter(ellipse => !ellipsoidSet.has(ellipse));
24
+
25
+ // If no missing ellipses, exit early
26
+ if (missingEllipses.length === 0) {
27
+ console.log('No missing ellipses found.');
28
+ process.exit(0);
29
+ }
30
+
31
+ // Open proj.db
32
+ const dbPath = path.resolve(__dirname, '../proj.db');
33
+ const db = new sqlite3.Database(dbPath);
34
+
35
+ // Query the ellipsoid table for missing ellipses
36
+ const placeholders = missingEllipses.map(() => '?').join(',');
37
+ const query = `
38
+ SELECT e.auth_name || ':' || e.code AS key,
39
+ e.semi_major_axis AS a,
40
+ e.inv_flattening AS rf,
41
+ e.name AS ellipseName
42
+ FROM ellipsoid e
43
+ WHERE e.name IN (${placeholders})
44
+ `;
45
+
46
+ db.all(query, missingEllipses, (err, rows) => {
47
+ if (err) {
48
+ console.error('Error querying proj.db:', err);
49
+ return;
50
+ }
51
+
52
+ // Add missing ellipsoids to the ellipsoids object
53
+ rows.forEach((row) => {
54
+ const key = row.key.replace(/:/g, '_'); // Replace ":" with "_" for valid JavaScript keys
55
+ ellipsoids[key] = {
56
+ a: row.a,
57
+ rf: row.rf,
58
+ ellipseName: row.ellipseName
59
+ };
60
+ });
61
+
62
+ // Write the updated ellipsoids object back to Ellipsoid.js
63
+ const ellipsoidFilePath = path.resolve(__dirname, '../lib/constants/Ellipsoid.js');
64
+ const ellipsoidContent = `var ellipsoids = ${JSON.stringify(ellipsoids, null, 2)};\n\nexport default ellipsoids;`;
65
+ fs.writeFileSync(ellipsoidFilePath, ellipsoidContent, 'utf-8');
66
+ console.log(`Ellipsoid.js updated successfully with ${rows.length} missing ellipsoids.`);
67
+ });
68
+
69
+ // Close the database connection
70
+ db.close();
package/test/opt.html CHANGED
@@ -1,25 +1,28 @@
1
- <html>
2
- <head>
3
- <meta charset="utf-8">
4
- <title>Mocha Tests</title>
5
- <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
6
- </head>
7
- <body><div id="mocha"></div>
8
- <script src="../node_modules/mocha/mocha.js"></script>
9
- <script src="../node_modules/chai/chai.js"></script>
10
- <script src="testData.js"></script>
11
- <script src="../dist/proj4.js"></script>
12
- <script src="test.js"></script>
13
- <script>
14
- mocha.setup({
15
- ui: "bdd",
16
- globals: ["console"],
17
- timeout: 300000,
18
- ignoreLeaks: true
19
- });
20
- startTests(chai,proj4,testPoints);
21
- if (window.mochaPhantomJS) { window.mochaPhantomJS.run(); }
22
- else { window.mocha.run(); }
23
- </script>
24
- </body>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Mocha Tests</title>
6
+ <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
7
+ </head>
8
+ <body><div id="mocha"></div>
9
+ <script src="../node_modules/mocha/mocha.js"></script>
10
+ <script src="../node_modules/chai/chai.js" type="module"></script>
11
+ <script src="testData.js"></script>
12
+ <script src="../dist/proj4.js"></script>
13
+ <script src="test.js"></script>
14
+ <script type="module">
15
+ import * as chai from '../node_modules/chai/chai.js';
16
+
17
+ mocha.setup({
18
+ reporter: "JSON",
19
+ ui: 'bdd',
20
+ globals: [],
21
+ timeout: 300000,
22
+ checkLeaks: false
23
+ });
24
+ startTests(chai,proj4,testPoints);
25
+ mocha.run();
26
+ </script>
27
+ </body>
25
28
  </html>
@@ -0,0 +1,110 @@
1
+ import puppeteer from 'puppeteer';
2
+ import http from 'http';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import assert from 'assert';
6
+
7
+ const hostname = process.env.HOST || '127.0.0.1'; // use hostname 127.0.0.1 unless there exists a preconfigured port
8
+ const port = process.env.PORT || 8080; // use port 8080 unless there exists a preconfigured port
9
+
10
+ const server = http.createServer(function (request, response) {
11
+ let filePath = request.url;
12
+
13
+ if (filePath === '/') {
14
+ filePath = 'index.html';
15
+ } else {
16
+ filePath = './' + request.url;
17
+ }
18
+
19
+ let extname = String(path.extname(filePath)).toLowerCase();
20
+ let mimeTypes = {
21
+ '.html': 'text/html',
22
+ '.js': 'text/javascript',
23
+ '.css': 'text/css',
24
+ '.json': 'application/json',
25
+ '.png': 'image/png',
26
+ '.jpg': 'image/jpg',
27
+ '.gif': 'image/gif',
28
+ '.svg': 'image/svg+xml',
29
+ '.wav': 'audio/wav',
30
+ '.mp4': 'video/mp4',
31
+ '.woff': 'application/font-woff',
32
+ '.ttf': 'application/font-ttf',
33
+ '.eot': 'application/vnd.ms-fontobject',
34
+ '.otf': 'application/font-otf',
35
+ '.wasm': 'application/wasm',
36
+ '.ico': 'image/x-icon'
37
+ };
38
+
39
+ let contentType = mimeTypes[extname] || 'application/octet-stream';
40
+
41
+ fs.readFile(filePath, function (error, content) {
42
+ if (error) {
43
+ if (error.code === 'ENOENT') {
44
+ fs.readFile('public/404.html', function (error, content) {
45
+ response.writeHead(404, { 'Content-Type': 'text/html' });
46
+ response.end(content, 'utf-8');
47
+ });
48
+ } else {
49
+ response.writeHead(500);
50
+ response.end('Sorry, check with the site admin for error: ' + error.code + ' ..\n');
51
+ }
52
+ } else {
53
+ response.writeHead(200, { 'Content-Type': contentType });
54
+ response.end(content, 'utf-8');
55
+ }
56
+ });
57
+ });
58
+ function timeoutPromise(timeout, callback) {
59
+ return new Promise((resolve, reject) => {
60
+ // Set up the timeout
61
+ const timer = setTimeout(() => {
62
+ reject(new Error(`Promise timed out after ${timeout} ms`));
63
+ }, timeout);
64
+
65
+ // Set up the real work
66
+ callback(
67
+ (value) => {
68
+ clearTimeout(timer);
69
+ resolve(value);
70
+ },
71
+ (error) => {
72
+ clearTimeout(timer);
73
+ reject(error);
74
+ }
75
+ );
76
+ });
77
+ }
78
+ (async () => {
79
+ server.listen(port, hostname);
80
+
81
+ // Launch the browser and open a new blank page
82
+
83
+ const browser = await puppeteer.launch({ headless: 'new', args: ['--no-sandbox'] });
84
+ const page = await browser.newPage();
85
+
86
+ // Navigate the page to a URL
87
+ await page.goto('http://' + hostname + ':' + port + '/test/opt.html');
88
+
89
+ // Set screen size
90
+ await page.setViewport({ width: 1080, height: 1024 });
91
+
92
+ // Type into search box
93
+ const testResult = await timeoutPromise(10000, (resolve) => {
94
+ page.on('console', (consoleMessage) => {
95
+ if (consoleMessage.type() === 'log') {
96
+ const res = JSON.parse(consoleMessage.text());
97
+ if (res.stats !== undefined) {
98
+ resolve(res.stats);
99
+ }
100
+ }
101
+ });
102
+ });
103
+
104
+ assert.strictEqual(testResult.failures, 0, 'Tests: passed: ' + testResult.passes + ', fail: ' + testResult.failures + ', total:' + testResult.tests);
105
+ assert.strictEqual(testResult.tests, testResult.passes, 'Tests: ' + testResult.passes + '/' + testResult.tests);
106
+ console.log('Tests: ' + testResult.passes + '/' + testResult.tests);
107
+
108
+ await browser.close();
109
+ server.close();
110
+ })();
@@ -0,0 +1,10 @@
1
+ import * as chai from 'chai';
2
+ import proj4 from '../dist/proj4-src.js';
3
+ import testData from './testData.js';
4
+ import startTests from './test.js';
5
+
6
+ if (typeof process !== 'undefined' && process.toString() === '[object process]') {
7
+ (async function () {
8
+ startTests(chai, proj4, testData);
9
+ })();
10
+ }