astro-viewer 3.1.0 → 3.2.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 (50) hide show
  1. package/dist/astroviewer.cjs +706 -204
  2. package/dist/astroviewer.js +1 -1
  3. package/dist/astroviewer.min.js +1 -1
  4. package/lib-esm/AstroSphere.d.ts +19 -15
  5. package/lib-esm/AstroSphere.js +163 -94
  6. package/lib-esm/AstroViewer.d.ts +2 -0
  7. package/lib-esm/AstroViewer.js +3 -0
  8. package/lib-esm/Camera.js +4 -6
  9. package/lib-esm/Config.d.ts +2 -0
  10. package/lib-esm/Config.js +3 -1
  11. package/lib-esm/index.d.ts +2 -0
  12. package/lib-esm/index.js +1 -0
  13. package/lib-esm/model/AbstractSkyEntity.d.ts +1 -0
  14. package/lib-esm/model/MetadataManager.d.ts +1 -0
  15. package/lib-esm/model/MetadataManager.js +4 -1
  16. package/lib-esm/model/Point.d.ts +9 -1
  17. package/lib-esm/model/Point.js +18 -0
  18. package/lib-esm/model/SphereFoV.js +4 -3
  19. package/lib-esm/model/earth/XYZConfig.d.ts +4 -0
  20. package/lib-esm/model/earth/XYZFoVHelper.d.ts +5 -2
  21. package/lib-esm/model/earth/XYZFoVHelper.js +40 -3
  22. package/lib-esm/model/footprints/Footprint.d.ts +4 -1
  23. package/lib-esm/model/footprints/Footprint.js +18 -2
  24. package/lib-esm/model/footprints/FootprintSetGL.d.ts +4 -2
  25. package/lib-esm/model/footprints/FootprintSetGL.js +9 -6
  26. package/lib-esm/model/grid/EquatorialGrid.d.ts +2 -1
  27. package/lib-esm/model/grid/EquatorialGrid.js +10 -6
  28. package/lib-esm/model/grid/HealpixGrid.js +5 -2
  29. package/lib-esm/model/grid/LonLatGrid.d.ts +3 -0
  30. package/lib-esm/model/grid/LonLatGrid.js +61 -10
  31. package/lib-esm/model/hips/FoVHelper.d.ts +5 -2
  32. package/lib-esm/model/hips/FoVHelper.js +40 -3
  33. package/lib-esm/model/hips/HiPS.d.ts +2 -0
  34. package/lib-esm/model/hips/HiPS.js +26 -5
  35. package/lib-esm/model/hips/HiPSConfig.d.ts +13 -0
  36. package/lib-esm/model/hips/HiPSConfig.js +1 -0
  37. package/lib-esm/model/hips/Tile.d.ts +1 -0
  38. package/lib-esm/model/hips/Tile.js +3 -0
  39. package/lib-esm/model/hips/TileBuffer.d.ts +5 -0
  40. package/lib-esm/model/hips/TileBuffer.js +49 -0
  41. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +6 -0
  42. package/lib-esm/model/terra/TerraFootprintSetGL.js +42 -0
  43. package/lib-esm/utils/CoordsType.d.ts +2 -1
  44. package/lib-esm/utils/CoordsType.js +1 -0
  45. package/lib-esm/utils/GeoJSONParser.d.ts +19 -0
  46. package/lib-esm/utils/GeoJSONParser.js +112 -0
  47. package/lib-esm/utils/PerspectiveMatrixManager.js +4 -1
  48. package/lib-esm/utils/STCSParser.d.ts +7 -3
  49. package/lib-esm/utils/STCSParser.js +15 -9
  50. package/package.json +2 -2
@@ -17,15 +17,15 @@ import { Point } from "../model/Point.js";
17
17
  import { CoordsType } from "./CoordsType.js";
18
18
  import global from "../Global.js";
19
19
  class STCSParser {
20
- static parseSTCS(stcs) {
20
+ static parseSTCS(stcs, options = {}) {
21
21
  const stcsParsed = STCSParser.cleanStcs(stcs);
22
22
  let totPoints = 0;
23
23
  const polygons = [];
24
24
  if (stcsParsed.includes("POLYGON")) {
25
- return STCSParser.parsePolygon(stcsParsed);
25
+ return STCSParser.parsePolygon(stcsParsed, options);
26
26
  }
27
27
  else if (stcsParsed.includes("CIRCLE")) {
28
- return STCSParser.parseCircle(stcsParsed);
28
+ return STCSParser.parseCircle(stcsParsed, options);
29
29
  }
30
30
  else {
31
31
  console.warn("STCS not recognised");
@@ -48,10 +48,11 @@ class STCSParser {
48
48
  s = s.replace(/ {2,}/g, ' ').trim();
49
49
  return s;
50
50
  }
51
- static parsePolygon(stcs) {
51
+ static parsePolygon(stcs, options = {}) {
52
52
  let totPoints = 0;
53
53
  const polygons = [];
54
54
  const MAX_DECIMALS = global.MAX_DECIMALS ?? 12;
55
+ const coordsType = options.coordsType ?? CoordsType.ASTRO;
55
56
  const polys = stcs.split("POLYGON ");
56
57
  for (let i = 1; i < polys.length; i++) {
57
58
  const currPoly = [];
@@ -66,9 +67,11 @@ class STCSParser {
66
67
  }
67
68
  if (points.length > 2) {
68
69
  for (let p = 0; p < points.length - 1; p += 2) {
69
- const raDeg = Number(parseFloat(points[p]).toFixed(MAX_DECIMALS));
70
- const decDeg = Number(parseFloat(points[p + 1]).toFixed(MAX_DECIMALS));
71
- const point = new Point({ raDeg, decDeg }, CoordsType.ASTRO);
70
+ const xDeg = Number(parseFloat(points[p]).toFixed(MAX_DECIMALS));
71
+ const yDeg = Number(parseFloat(points[p + 1]).toFixed(MAX_DECIMALS));
72
+ const point = coordsType === CoordsType.GEOGRAPHIC
73
+ ? new Point({ lonDeg: xDeg, latDeg: yDeg }, CoordsType.GEOGRAPHIC)
74
+ : new Point({ raDeg: xDeg, decDeg: yDeg }, CoordsType.ASTRO);
72
75
  currPoly.push(point);
73
76
  totPoints += 1;
74
77
  }
@@ -78,9 +81,10 @@ class STCSParser {
78
81
  return { totpoints: totPoints, polygons };
79
82
  }
80
83
  // Example format: "CIRCLE ICRS 8.739685 4.38147 0.027833"
81
- static parseCircle(stcs) {
84
+ static parseCircle(stcs, options = {}) {
82
85
  let totPoints = 0;
83
86
  const polygons = [];
87
+ const coordsType = options.coordsType ?? CoordsType.ASTRO;
84
88
  const polys = stcs.split("CIRCLE ");
85
89
  for (let i = 1; i < polys.length; i++) {
86
90
  const currPoly = [];
@@ -95,7 +99,9 @@ class STCSParser {
95
99
  for (let p = npoints; p > 0; p--) {
96
100
  const curra = radius * Math.cos(p * alpha) + ra;
97
101
  const curdec = radius * Math.sin(p * alpha) + dec;
98
- const point = new Point({ raDeg: curra, decDeg: curdec }, CoordsType.ASTRO);
102
+ const point = coordsType === CoordsType.GEOGRAPHIC
103
+ ? new Point({ lonDeg: curra, latDeg: curdec }, CoordsType.GEOGRAPHIC)
104
+ : new Point({ raDeg: curra, decDeg: curdec }, CoordsType.ASTRO);
99
105
  currPoly.push(point);
100
106
  totPoints += 1;
101
107
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "astro-viewer",
3
3
  "description": "Astrobrowser 3d engine.",
4
- "version": "3.1.0",
4
+ "version": "3.2.0",
5
5
  "keywords": [
6
6
  "HiPS",
7
7
  "HiPS cutout",
@@ -49,7 +49,7 @@
49
49
  "prod": "npm run clean && tsc -p tsconfig.build.json && webpack --mode=production && npm run web",
50
50
  "build": "npm run clean && tsc -p tsconfig.build.json && webpack --mode=production",
51
51
  "web": "cp dist/* public/javascripts/; cp -R src/html/javascripts/ public/javascripts/; cp -R src/html/css/ public/css/; cp src/html/*.html public/",
52
- "start-server": "python3 -m http.server 8080 -d public",
52
+ "start-server": "npm run web; python3 -m http.server 8080 -d public",
53
53
  "all": "npm run clean; npm run prod; npm run start-server",
54
54
  "prepublishOnly": "npm run build"
55
55
  },