@mapcatch/util 1.0.0

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 (71) hide show
  1. package/.eslintrc.js +53 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGELOG.md +0 -0
  4. package/README.md +44 -0
  5. package/docs/Catolog.md +24 -0
  6. package/docs/Util.md +170 -0
  7. package/package.json +30 -0
  8. package/src/constants/cameras.js +5 -0
  9. package/src/constants/index.js +1 -0
  10. package/src/event.js +205 -0
  11. package/src/exif/exif.js +37 -0
  12. package/src/exif/gps_tags.js +33 -0
  13. package/src/exif/ifd1_tags.js +22 -0
  14. package/src/exif/index.js +16 -0
  15. package/src/exif/iptc_field_map.js +12 -0
  16. package/src/exif/parse_image.js +446 -0
  17. package/src/exif/string_values.js +137 -0
  18. package/src/exif/tags.js +75 -0
  19. package/src/exif/tiff_tags.js +35 -0
  20. package/src/exif/util.js +108 -0
  21. package/src/gl-operations/constants.js +11 -0
  22. package/src/gl-operations/default_options.js +98 -0
  23. package/src/gl-operations/index.js +594 -0
  24. package/src/gl-operations/reglCommands/contours.js +27 -0
  25. package/src/gl-operations/reglCommands/default.js +44 -0
  26. package/src/gl-operations/reglCommands/hillshading.js +332 -0
  27. package/src/gl-operations/reglCommands/index.js +6 -0
  28. package/src/gl-operations/reglCommands/multiLayers.js +301 -0
  29. package/src/gl-operations/reglCommands/transitions.js +109 -0
  30. package/src/gl-operations/reglCommands/util.js +71 -0
  31. package/src/gl-operations/renderer.js +193 -0
  32. package/src/gl-operations/shaders/fragment/convertDem.js +26 -0
  33. package/src/gl-operations/shaders/fragment/convolutionSmooth.js +55 -0
  34. package/src/gl-operations/shaders/fragment/diffCalc.js +34 -0
  35. package/src/gl-operations/shaders/fragment/drawResult.js +42 -0
  36. package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +79 -0
  37. package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +55 -0
  38. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +31 -0
  39. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +56 -0
  40. package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +27 -0
  41. package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +26 -0
  42. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +54 -0
  43. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +81 -0
  44. package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +50 -0
  45. package/src/gl-operations/shaders/fragment/interpolateColor.js +63 -0
  46. package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +47 -0
  47. package/src/gl-operations/shaders/fragment/interpolateValue.js +124 -0
  48. package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +36 -0
  49. package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +46 -0
  50. package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +54 -0
  51. package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +62 -0
  52. package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +70 -0
  53. package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +78 -0
  54. package/src/gl-operations/shaders/fragment/single.js +88 -0
  55. package/src/gl-operations/shaders/transform.js +22 -0
  56. package/src/gl-operations/shaders/util/computeColor.glsl +84 -0
  57. package/src/gl-operations/shaders/util/getTexelValue.glsl +10 -0
  58. package/src/gl-operations/shaders/util/isCloseEnough.glsl +9 -0
  59. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +18 -0
  60. package/src/gl-operations/shaders/vertex/double.js +17 -0
  61. package/src/gl-operations/shaders/vertex/multi3.js +20 -0
  62. package/src/gl-operations/shaders/vertex/multi4.js +23 -0
  63. package/src/gl-operations/shaders/vertex/multi5.js +26 -0
  64. package/src/gl-operations/shaders/vertex/multi6.js +29 -0
  65. package/src/gl-operations/shaders/vertex/single.js +13 -0
  66. package/src/gl-operations/shaders/vertex/singleNotTransformed.js +12 -0
  67. package/src/gl-operations/texture_manager.js +141 -0
  68. package/src/gl-operations/util.js +336 -0
  69. package/src/index.js +10 -0
  70. package/src/util.js +332 -0
  71. package/vite.config.js +52 -0
@@ -0,0 +1,108 @@
1
+ export default {
2
+ imageHasData(img) {
3
+ return !!(img.exifdata);
4
+ },
5
+ getStringFromDB(buffer, start, length) {
6
+ var outstr = "";
7
+ for (var n = start; n < start + length; n++) {
8
+ outstr += String.fromCharCode(buffer.getUint8(n));
9
+ }
10
+ return outstr;
11
+ },
12
+ xml2Object(xml) {
13
+ try {
14
+ var obj = {};
15
+ if (xml.children.length > 0) {
16
+ for (var i = 0; i < xml.children.length; i++) {
17
+ var item = xml.children.item(i);
18
+ var attributes = item.attributes;
19
+ for (var idx in attributes) {
20
+ var itemAtt = attributes[idx];
21
+ var dataKey = itemAtt.nodeName;
22
+ var dataValue = itemAtt.nodeValue;
23
+
24
+ if (dataKey !== undefined) {
25
+ obj[dataKey] = dataValue;
26
+ }
27
+ }
28
+ var nodeName = item.nodeName;
29
+
30
+ if (typeof (obj[nodeName]) == "undefined") {
31
+ obj[nodeName] = this.xml2json(item);
32
+ } else {
33
+ if (typeof (obj[nodeName].push) == "undefined") {
34
+ var old = obj[nodeName];
35
+
36
+ obj[nodeName] = [];
37
+ obj[nodeName].push(old);
38
+ }
39
+ obj[nodeName].push(this.xml2json(item));
40
+ }
41
+ }
42
+ } else {
43
+ obj = xml.textContent;
44
+ }
45
+ return obj;
46
+ } catch (e) {
47
+ console.log(e.message);
48
+ }
49
+ },
50
+ xml2json(xml) {
51
+ var json = {};
52
+
53
+ if (xml.nodeType == 1) { // element node
54
+ if (xml.attributes.length > 0) {
55
+ json['@attributes'] = {};
56
+ for (var j = 0; j < xml.attributes.length; j++) {
57
+ var attribute = xml.attributes.item(j);
58
+ json['@attributes'][attribute.nodeName] = attribute.nodeValue;
59
+ }
60
+ }
61
+ } else if (xml.nodeType == 3) { // text node
62
+ return xml.nodeValue;
63
+ }
64
+
65
+ // deal with children
66
+ if (xml.hasChildNodes()) {
67
+ for (var i = 0; i < xml.childNodes.length; i++) {
68
+ var child = xml.childNodes.item(i);
69
+ var nodeName = child.nodeName;
70
+ if (json[nodeName] == null) {
71
+ json[nodeName] = this.xml2json(child);
72
+ } else {
73
+ if (json[nodeName].push == null) {
74
+ var old = json[nodeName];
75
+ json[nodeName] = [];
76
+ json[nodeName].push(old);
77
+ }
78
+ json[nodeName].push(this.xml2json(child));
79
+ }
80
+ }
81
+ }
82
+
83
+ return json;
84
+ },
85
+ objectURLToBlob(url, callback) {
86
+ var http = new XMLHttpRequest();
87
+ http.open("GET", url, true);
88
+ http.responseType = "blob";
89
+ http.onload = function (e) {
90
+ if (this.status == 200 || this.status === 0) {
91
+ callback(this.response);
92
+ }
93
+ };
94
+ http.send();
95
+ },
96
+ base64ToArrayBuffer(base64, contentType) {
97
+ contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg'
98
+ base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
99
+ var binary = atob(base64);
100
+ var len = binary.length;
101
+ var buffer = new ArrayBuffer(len);
102
+ var view = new Uint8Array(buffer);
103
+ for (var i = 0; i < len; i++) {
104
+ view[i] = binary.charCodeAt(i);
105
+ }
106
+ return buffer;
107
+ }
108
+ }
@@ -0,0 +1,11 @@
1
+ import REGL from 'regl';
2
+
3
+ export const CLEAR_COLOR = [0, 0, 0, 0];
4
+ export const MAX_TEXTURE_DIMENSION = 1024;
5
+ export const EARTH_SUN_DISTANCE = 149600000000;
6
+ export const EARTH_CIRCUMFERENCE = 40075016.686;
7
+ export const SUN_RADIUS = 695508000;
8
+ export const DEG2RAD = 0.017453292519943295;
9
+ export const SLOPEFACTOR = 0.0333334;
10
+ export const RGB_REGEX = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
11
+ export const HEX_REGEX = /(?:#)[0-9a-f]{8}|(?:#)[0-9a-f]{6}|(?:#)[0-9a-f]{4}|(?:#)[0-9a-f]{3}/ig;
@@ -0,0 +1,98 @@
1
+ const defaultOptions = {
2
+ tileFormat: 'float32',
3
+ tileSize: 256,
4
+ colorScale: [],
5
+ sentinelValues: [],
6
+ transitions: false,
7
+ transitionTimeMs: 800,
8
+ debug: false,
9
+ extraPixelLayers: 0,
10
+ colorscaleMaxLength: 16,
11
+ sentinelMaxLength: 16,
12
+
13
+ // default TileLayer options
14
+ minZoom: 0,
15
+ maxZoom: 18,
16
+ subdomains: 'abc',
17
+ errorTileUrl: '',
18
+ zoomOffset: 0,
19
+ tms: false,
20
+ zoomReverse: false,
21
+ detectRetina: false,
22
+ crossOrigin: false,
23
+
24
+ // multi-analyze default options
25
+ glOperation: 'none',
26
+ multiLayers: 0,
27
+ operationUrlA: '',
28
+ operationUrlB: '',
29
+ operationUrlC: '',
30
+ operationUrlD: '',
31
+ operationUrlE: '',
32
+ operationUrlF: '',
33
+ filterLowA: 0,
34
+ filterHighA: 100000,
35
+ filterLowB: 0,
36
+ filterHighB: 100000,
37
+ filterLowC: 0,
38
+ filterHighC: 100000,
39
+ filterLowD: 0,
40
+ filterHighD: 100000,
41
+ filterLowE: 0,
42
+ filterHighE: 100000,
43
+ filterLowF: 0,
44
+ filterHighF: 100000,
45
+ multiplierA: 1,
46
+ multiplierB: 1,
47
+ multiplierC: 1,
48
+ multiplierD: 1,
49
+ multiplierE: 1,
50
+ multiplierF: 1,
51
+
52
+ // Hillshading default options
53
+ hillshadeType: 'none', // none, simple or pregen
54
+ hsSimpleZoomdelta: 0,
55
+ hsSimpleSlopescale: 3.0,
56
+ hsSimpleAzimuth: 315,
57
+ hsSimpleAltitude: 70,
58
+ hsAdvValueScale: 1.0,
59
+ hsAdvPixelScale: 'auto',
60
+ hsAdvSoftIterations: 10,
61
+ hsAdvAmbientIterations: 10,
62
+ hsAdvSunRadiusMultiplier: 100,
63
+ hsAdvFinalSoftMultiplier: 1.0,
64
+ hsAdvFinalAmbientMultiplier: 0.25,
65
+ hsAdvBaselayerUrl: '',
66
+ hsAdvSmoothInput: false,
67
+ hsAdvSmoothInputKernel: 3,
68
+ hsPregenUrl: '',
69
+ _hillshadeOptions: { hillshadeType: 'none' },
70
+
71
+ // Contours default options
72
+ contourType: 'none', // none, lines or illuminated
73
+ contourSmoothLines: false,
74
+ contourSmoothInput: false,
75
+ contourSmoothInputKernel: 7,
76
+ contourScaleFactor: 1,
77
+ contourInterval: 25,
78
+ contourIndexInterval: 100,
79
+ contourLineColor: '#000000',
80
+ contourIlluminatedHighlightColor: 'rgba(177,174,164,.5)',
81
+ contourIlluminatedShadowColor: '#5b5143',
82
+ contourIlluminatedShadowSize: 2, // px
83
+ contourLineWeight: 0.5, // px
84
+ contourLineIndexWeight: 2.0, // px
85
+ contourIndexLabels: false,
86
+ contourLabelFont: '12px Arial',
87
+ contourLabelDistance: 250,
88
+ contourHypso: false,
89
+ contourHypsoDomain: [0, 1000, 2000],
90
+ contourHypsoColors: ["#486341", "#e5d9c9", "#dddddd"],
91
+ contourBathy: false,
92
+ contourBathyDomain: [-2000, 0],
93
+ contourBathyColors: ["#315d9b", "#d5f2ff"],
94
+ contourBathyShadowColor: '#4e5c66',
95
+ contourBathyHighlightColor: 'rgba(224, 242, 255, .5)',
96
+ };
97
+
98
+ export default defaultOptions