celestial-chart 0.8.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.
- package/CHANGELOG.md +105 -0
- package/LICENSE +13 -0
- package/NOTICE.md +41 -0
- package/README.md +192 -0
- package/build/celestial.cjs +15354 -0
- package/build/celestial.js +15330 -0
- package/build/celestial.min.js +7 -0
- package/build/celestial.mjs +15333 -0
- package/celestial.css +111 -0
- package/images/dtpick.png +0 -0
- package/lib/geo-zoom.js +116 -0
- package/package.json +89 -0
- package/src/add.js +46 -0
- package/src/canvas.js +269 -0
- package/src/celestial.js +1177 -0
- package/src/config.js +537 -0
- package/src/core.js +14 -0
- package/src/d3.js +28 -0
- package/src/datetimepicker.js +233 -0
- package/src/form.js +837 -0
- package/src/get.js +210 -0
- package/src/global.js +4 -0
- package/src/horizontal.js +98 -0
- package/src/index.js +8 -0
- package/src/kepler.js +481 -0
- package/src/location.js +359 -0
- package/src/moon.js +522 -0
- package/src/projection.js +205 -0
- package/src/svg.js +879 -0
- package/src/timezones.js +71 -0
- package/src/transform.js +94 -0
- package/src/util.js +275 -0
- package/types/celestial.d.ts +545 -0
package/src/config.js
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import * as d3 from "./d3.js";
|
|
2
|
+
import { Celestial } from "./core.js";
|
|
3
|
+
import { has, isArray } from "./util.js";
|
|
4
|
+
|
|
5
|
+
// Central configuration object
|
|
6
|
+
var globalConfig = {};
|
|
7
|
+
|
|
8
|
+
//Defaults
|
|
9
|
+
var settings = {
|
|
10
|
+
width: 0, // Default width; height is determined by projection
|
|
11
|
+
projection: "aitoff", // Map projection used: airy, aitoff, armadillo, august, azimuthalEqualArea, azimuthalEquidistant, baker, berghaus, boggs, bonne, bromley, collignon, craig, craster, cylindricalEqualArea, cylindricalStereographic, eckert1, eckert2, eckert3, eckert4, eckert5, eckert6, eisenlohr, equirectangular, fahey, foucaut, ginzburg4, ginzburg5, ginzburg6, ginzburg8, ginzburg9, gringorten, hammer, hatano, healpix, hill, homolosine, kavrayskiy7, lagrange, larrivee, laskowski, loximuthal, mercator, miller, mollweide, mtFlatPolarParabolic, mtFlatPolarQuartic, mtFlatPolarSinusoidal, naturalEarth, nellHammer, orthographic, patterson, polyconic, rectangularPolyconic, robinson, sinusoidal, stereographic, times, twoPointEquidistant, vanDerGrinten, vanDerGrinten2, vanDerGrinten3, vanDerGrinten4, wagner4, wagner6, wagner7, wiechel, winkel3
|
|
12
|
+
projectionRatio: null, // Optional override for default projection ratio
|
|
13
|
+
transform: "equatorial", // Coordinate transformation: equatorial (default), ecliptic, galactic, supergalactic
|
|
14
|
+
center: null, // Initial center coordinates in equatorial transformation [hours, degrees, degrees],
|
|
15
|
+
// otherwise [degrees, degrees, degrees], 3rd parameter is orientation, null = default center
|
|
16
|
+
geopos: null, // optional initial geographic position [lat,lon] in degrees, overrides center
|
|
17
|
+
follow: "zenith", // on which coordinates to center the map, default: zenith, if location enabled, otherwise center
|
|
18
|
+
orientationfixed: true, // Keep orientation angle the same as center[2]
|
|
19
|
+
zoomlevel: null, // initial zoom level 0...zoomextend; 0|null = default, 1 = 100%, 0 < x <= zoomextend
|
|
20
|
+
zoomextend: 10, // maximum zoom level
|
|
21
|
+
adaptable: true, // Sizes are increased with higher zoom-levels
|
|
22
|
+
interactive: true, // Enable zooming and rotation with mousewheel and dragging
|
|
23
|
+
disableAnimations: false, // Disable all animations
|
|
24
|
+
form: false, // Display settings form
|
|
25
|
+
location: false, // Display location settings, deprecated, use formFields
|
|
26
|
+
// Set visiblity for each group of fields of the form
|
|
27
|
+
formFields: {"location": true, "general": true, "stars": true, "dsos": true, "constellations": true, "lines": true, "other": true, download: false},
|
|
28
|
+
advanced: true, // Display fewer form fields if false
|
|
29
|
+
daterange: [], // Calender date range; null: displaydate-+10; [n<100]: displaydate-+n; [yr]: yr-+10;
|
|
30
|
+
// [yr, n<100]: [yr-n, yr+n]; [yr0, yr1]
|
|
31
|
+
settimezone: true, // Automatcally set time zone when geolocation changes
|
|
32
|
+
timezoneid: "", // Your own TimeZoneDB account id. Empty: no request is made,
|
|
33
|
+
// the offset is estimated from longitude. See timezoneResolver.
|
|
34
|
+
timezoneResolver: null, // (lat, lon, whenSeconds) => Promise<offsetInMinutes>, or null.
|
|
35
|
+
// Takes precedence over timezoneid; lets you point at your own
|
|
36
|
+
// service instead of sending visitor coordinates to a third party.
|
|
37
|
+
controls: true, // Display zoom controls
|
|
38
|
+
lang: "", // Global language override for names, any name setting that has the chosen language available
|
|
39
|
+
// Default: desig or empty string for designations, other languages as used anywhere else
|
|
40
|
+
culture: "", // Constellation lines, default "iau"
|
|
41
|
+
container: "celestial-map", // ID of parent element, e.g. div
|
|
42
|
+
datapath: "data/", // Path/URL to data files, empty = subfolder 'data'
|
|
43
|
+
stars: {
|
|
44
|
+
show: true, // Show stars
|
|
45
|
+
limit: 6, // Show only stars brighter than limit magnitude
|
|
46
|
+
colors: true, // Show stars in spectral colors, if not use fill-style
|
|
47
|
+
style: { fill: "#ffffff", opacity: 1 }, // Default style for stars
|
|
48
|
+
designation: true, // Show star names (Bayer, Flamsteed, Variable star, Gliese or designation,
|
|
49
|
+
// i.e. whichever of the previous applies first); may vary with culture setting
|
|
50
|
+
designationType: "desig", // Which kind of name is displayed as designation (fieldname in starnames.json)
|
|
51
|
+
designationStyle: { fill: "#ddddbb", font: "11px 'Palatino Linotype', Georgia, Times, 'Times Roman', serif", align: "left", baseline: "top" },
|
|
52
|
+
designationLimit: 2.5, // Show only names for stars brighter than nameLimit
|
|
53
|
+
propername: false, // Show proper name (if present)
|
|
54
|
+
propernameType: "name", // Field in starnames.json that contains proper name; may vary with culture setting
|
|
55
|
+
propernameStyle: { fill: "#ddddbb", font: "13px 'Palatino Linotype', Georgia, Times, 'Times Roman', serif", align: "right", baseline: "bottom" },
|
|
56
|
+
propernameLimit: 1.5, // Show proper names for stars brighter than propernameLimit
|
|
57
|
+
size: 7, // Scale size (radius) of star circle in pixels
|
|
58
|
+
exponent: -0.28, // Scale exponent for star size, larger = more linear
|
|
59
|
+
data: "stars.6.json" // Data source for stellar data
|
|
60
|
+
},
|
|
61
|
+
dsos: {
|
|
62
|
+
show: true, // Show Deep Space Objects
|
|
63
|
+
limit: 6, // Show only DSOs brighter than limit magnitude
|
|
64
|
+
colors: true, // Show DSOs in symbol colors if true, use style setting below if false
|
|
65
|
+
style: { fill: "#cccccc", stroke: "#cccccc", width: 2, opacity: 1 }, // Default style for dsos
|
|
66
|
+
names: true, // Show DSO names
|
|
67
|
+
namesType: "desig", // Type of displayed name: desig, name, or 15 different language codes from dsonames.json
|
|
68
|
+
nameStyle: { fill: "#cccccc", font: "11px 'Lucida Sans Unicode', 'DejaVu Sans', Helvetica, Arial, serif", align: "left", baseline: "bottom" },
|
|
69
|
+
nameLimit: 4, // Show only names for DSOs brighter than nameLimit
|
|
70
|
+
size: null, // Optional seperate scale size for DSOs, null = stars.size
|
|
71
|
+
exponent: 1.4, // Scale exponent for DSO size, larger = more non-linear
|
|
72
|
+
data: "dsos.bright.json", // Data source for DSOs
|
|
73
|
+
symbols: { // DSO symbol styles
|
|
74
|
+
gg: {shape: "circle", fill: "#ff0000"}, // Galaxy cluster
|
|
75
|
+
g: {shape: "ellipse", fill: "#ff0000"}, // Generic galaxy
|
|
76
|
+
s: {shape: "ellipse", fill: "#ff0000"}, // Spiral galaxy
|
|
77
|
+
s0: {shape: "ellipse", fill: "#ff0000"}, // Lenticular galaxy
|
|
78
|
+
sd: {shape: "ellipse", fill: "#ff0000"}, // Dwarf galaxy
|
|
79
|
+
e: {shape: "ellipse", fill: "#ff0000"}, // Elliptical galaxy
|
|
80
|
+
i: {shape: "ellipse", fill: "#ff0000"}, // Irregular galaxy
|
|
81
|
+
oc: {shape: "circle", fill: "#ff9900", stroke: "#ff9900", width: 2}, // Open cluster
|
|
82
|
+
gc: {shape: "circle", fill: "#ff9900"}, // Globular cluster
|
|
83
|
+
en: {shape: "square", fill: "#ff00cc"}, // Emission nebula
|
|
84
|
+
bn: {shape: "square", fill: "#ff00cc"}, // Generic bright nebula
|
|
85
|
+
sfr:{shape: "square", fill: "#cc00ff"}, // Star forming region
|
|
86
|
+
rn: {shape: "square", fill: "#0000ff"}, // Reflection nebula
|
|
87
|
+
pn: {shape: "diamond", fill: "#00cccc"}, // Planetary nebula
|
|
88
|
+
snr:{shape: "diamond", fill: "#ff00cc"}, // Supernova remnant
|
|
89
|
+
dn: {shape: "square", fill: "#999999", stroke: "#999999", width: 2}, // Dark nebula
|
|
90
|
+
pos:{shape: "marker", fill: "#cccccc", stroke: "#cccccc", width: 1.5} // Generic marker
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
constellations: {
|
|
94
|
+
show: true, // Show constellations
|
|
95
|
+
names: true, // Show constellation names
|
|
96
|
+
namesType: "desig", // What kind of name to show (default 3 letter designations) all options: name, desig,
|
|
97
|
+
// lat, en, ar, cn, cz, ee, fi, fr, de, gr, il, it, jp, kr, in, ir, ru, es, tr
|
|
98
|
+
nameStyle: { fill:"#cccc99", align: "center", baseline: "middle", opacity:0.8,
|
|
99
|
+
font: ["14px 'Lucida Sans Unicode', 'DejaVu Sans', Helvetica, Arial, sans-serif", // Different fonts for brighter &
|
|
100
|
+
"12px 'Lucida Sans Unicode', 'DejaVu Sans', Helvetica, Arial, sans-serif", // darker constellations
|
|
101
|
+
"11px 'Lucida Sans Unicode', 'DejaVu Sans', Helvetica, Arial, sans-serif"]},
|
|
102
|
+
lines: true, // Show constellation lines
|
|
103
|
+
lineStyle: { stroke: "#cccccc", width: 1.5, opacity: 0.6 },
|
|
104
|
+
bounds: false, // Show constellation boundaries
|
|
105
|
+
boundStyle: { stroke: "#ccff00", width: 1.0, opacity: 0.8, dash: [4,4] }
|
|
106
|
+
},
|
|
107
|
+
mw: {
|
|
108
|
+
show: true, // Show Milky Way as filled polygons
|
|
109
|
+
style: { fill: "#ffffff", opacity: "0.15" } // style for each MW-layer (5 on top of each other)
|
|
110
|
+
},
|
|
111
|
+
lines: {
|
|
112
|
+
graticule: { show: true, stroke: "#cccccc", width: 0.6, opacity: 0.8, // Show graticule lines
|
|
113
|
+
// grid values: "outline", "center", or [lat,...] specific position
|
|
114
|
+
lon: {pos: [], fill: "#eee", font: "10px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif"},
|
|
115
|
+
// grid values: "outline", "center", or [lon,...] specific position
|
|
116
|
+
lat: {pos: [], fill: "#eee", font: "10px 'Lucida Sans Unicode', Helvetica, Arial, sans-serif"}},
|
|
117
|
+
equatorial: { show: true, stroke: "#aaaaaa", width: 1.3, opacity: 0.7 }, // Show equatorial plane
|
|
118
|
+
ecliptic: { show: true, stroke: "#66cc66", width: 1.3, opacity: 0.7 }, // Show ecliptic plane
|
|
119
|
+
galactic: { show: false, stroke: "#cc6666", width: 1.3, opacity: 0.7 }, // Show galactic plane
|
|
120
|
+
supergalactic: { show: false, stroke: "#cc66cc", width: 1.3, opacity: 0.7 } // Show supergalactic plane
|
|
121
|
+
//mars: { show: false, stroke:"#cc0000", width:1.3, opacity:.7 }
|
|
122
|
+
}, // Background style
|
|
123
|
+
background: {
|
|
124
|
+
fill: "#000000",
|
|
125
|
+
opacity: 1,
|
|
126
|
+
stroke: "#000000", // Outline
|
|
127
|
+
width: 1.5
|
|
128
|
+
},
|
|
129
|
+
horizon: { //Show horizon marker, if geo-position and date-time is set
|
|
130
|
+
show: false,
|
|
131
|
+
stroke: "#cccccc", // Line
|
|
132
|
+
width: 1.0,
|
|
133
|
+
fill: "#000000", // Area below horizon
|
|
134
|
+
opacity: 0.4
|
|
135
|
+
},
|
|
136
|
+
daylight: { //Show approximate state of sky at selected time
|
|
137
|
+
show: false
|
|
138
|
+
},
|
|
139
|
+
planets: { //Show planet locations, if date-time is set
|
|
140
|
+
show: false,
|
|
141
|
+
// 3-letter designations of all solar system objects that should be displayed
|
|
142
|
+
which: ["sol", "mer", "ven", "ter", "lun", "mar", "jup", "sat", "ura", "nep", "cer", "plu"],
|
|
143
|
+
// Symbols as unicode codepoints, letter abbreviations and colors to be displayed
|
|
144
|
+
symbols: {
|
|
145
|
+
"sol": {symbol: "\u2609", letter:"Su", fill: "#ffff00", size: 12},
|
|
146
|
+
"mer": {symbol: "\u263f", letter:"Me", fill: "#cccccc"},
|
|
147
|
+
"ven": {symbol: "\u2640", letter:"V", fill: "#eeeecc"},
|
|
148
|
+
"ter": {symbol: "\u2295", letter:"T", fill: "#00ccff"},
|
|
149
|
+
"lun": {symbol: "\u25cf", letter:"L", fill: "#ffffff", size: 12},
|
|
150
|
+
"mar": {symbol: "\u2642", letter:"Ma", fill: "#ff6600"},
|
|
151
|
+
"cer": {symbol: "\u26b3", letter:"C", fill: "#cccccc"},
|
|
152
|
+
"ves": {symbol: "\u26b6", letter:"Ma", fill: "#cccccc"},
|
|
153
|
+
"jup": {symbol: "\u2643", letter:"J", fill: "#ffaa33"},
|
|
154
|
+
"sat": {symbol: "\u2644", letter:"Sa", fill: "#ffdd66"},
|
|
155
|
+
"ura": {symbol: "\u2645", letter:"U", fill: "#66ccff"},
|
|
156
|
+
"nep": {symbol: "\u2646", letter:"N", fill: "#6666ff"},
|
|
157
|
+
"plu": {symbol: "\u2647", letter:"P", fill: "#aaaaaa"},
|
|
158
|
+
"eri": {symbol: "\u26aa", letter:"E", fill: "#eeeeee"}
|
|
159
|
+
},
|
|
160
|
+
// Style options for planetary symbols
|
|
161
|
+
symbolStyle: { fill: "#cccccc", opacity:1, font: "bold 20px 'DejaVu Sans Mono', 'Arial Unicode MS', sans-serif", align: "center", baseline: "middle" },
|
|
162
|
+
symbolType: "symbol", // Type of planetary symbol to be displayed: 'symbol', 'letter' or 'disk'
|
|
163
|
+
names: false, // Show name next to symbol
|
|
164
|
+
// Style options for planetary names
|
|
165
|
+
nameStyle: { fill: "#cccccc", font: "14px 'Lucida Sans Unicode', 'DejaVu Sans', sans-serif", align: "right", baseline: "top" },
|
|
166
|
+
namesType: "en" // Language in which the name is displayed, options desig, ar, cn, en, fr, de, gr, il, in, it, jp, lat, ru, es
|
|
167
|
+
},
|
|
168
|
+
// The `base` parameter is what makes instances possible: without it every
|
|
169
|
+
// call started from the module-level globalConfig, so a second map inherited
|
|
170
|
+
// the first one's settings (upstream #96, #131). Given a base, it starts from
|
|
171
|
+
// that and does not write back to the global either — so two maps cannot see
|
|
172
|
+
// into each other's configuration. Without a base the original behaviour
|
|
173
|
+
// stands, so that Celestial.settings() keeps working.
|
|
174
|
+
set: function(cfg, base) { // Override defaults with values of cfg
|
|
175
|
+
var prop, key, config = {}, res = {};
|
|
176
|
+
if (base) Object.assign(config, base);
|
|
177
|
+
else if (Object.entries(globalConfig).length === 0) Object.assign(config, this);
|
|
178
|
+
else Object.assign(config, globalConfig);
|
|
179
|
+
if (!cfg) return config;
|
|
180
|
+
for (prop in config) {
|
|
181
|
+
if (!has(config, prop)) continue;
|
|
182
|
+
//if (typeof(config[prop]) === 'function');
|
|
183
|
+
if (!has(cfg, prop) || cfg[prop] === null) {
|
|
184
|
+
res[prop] = config[prop];
|
|
185
|
+
} else if (config[prop] === null || config[prop].constructor != Object ) {
|
|
186
|
+
res[prop] = cfg[prop];
|
|
187
|
+
} else {
|
|
188
|
+
res[prop] = {};
|
|
189
|
+
for (key in config[prop]) {
|
|
190
|
+
if (has(cfg[prop], key)) {
|
|
191
|
+
res[prop][key] = cfg[prop][key];
|
|
192
|
+
} else {
|
|
193
|
+
res[prop][key] = config[prop][key];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
res.constellations.nameStyle.font = arrayfy(res.constellations.nameStyle.font);
|
|
199
|
+
res.constellations.nameStyle.opacity = arrayfy(res.constellations.nameStyle.opacity);
|
|
200
|
+
res.constellations.nameStyle.fill = arrayfy(res.constellations.nameStyle.fill);
|
|
201
|
+
res.constellations.lineStyle.width = arrayfy(res.constellations.lineStyle.width);
|
|
202
|
+
res.constellations.lineStyle.opacity = arrayfy(res.constellations.lineStyle.opacity);
|
|
203
|
+
res.constellations.lineStyle.stroke = arrayfy(res.constellations.lineStyle.stroke);
|
|
204
|
+
|
|
205
|
+
if (!base) Object.assign(globalConfig, res);
|
|
206
|
+
return res;
|
|
207
|
+
},
|
|
208
|
+
applyDefaults: function(cfg, base) {
|
|
209
|
+
var res = {};
|
|
210
|
+
// In the chain this is called on the result of set(), so `this` is the
|
|
211
|
+
// already-merged configuration. The standalone branch has to continue from
|
|
212
|
+
// there — starting from globalConfig would discard the caller's settings.
|
|
213
|
+
Object.assign(res, base ? this : globalConfig);
|
|
214
|
+
// Nothing works without these
|
|
215
|
+
res.stars.size = res.stars.size || 7;
|
|
216
|
+
res.stars.exponent = res.stars.exponent || -0.28;
|
|
217
|
+
if (!res.center || res.center.length <= 0) res.center = [0,0,0];
|
|
218
|
+
res.datapath = res.datapath || "";
|
|
219
|
+
res.datapath = res.datapath.replace(/([^\/]$)/, "$1\/");
|
|
220
|
+
if (!res.transform || res.transform === "") res.transform = "equatorial";
|
|
221
|
+
// If no recognized language/culture settings, assume defaults
|
|
222
|
+
//if (!res.lang || res.lang.search(/^de|es$/) === -1) res.lang = "name";
|
|
223
|
+
//Set all poss. names to cfg.lang if not english
|
|
224
|
+
if (!res.culture || res.culture.search(/^cn$/) === -1) res.culture = "iau";
|
|
225
|
+
|
|
226
|
+
if (cfg) {
|
|
227
|
+
// Adapt legacy name parameters
|
|
228
|
+
if (has(cfg, "stars")) {
|
|
229
|
+
// names -> designation
|
|
230
|
+
if (has(cfg.stars, "names")) res.stars.designation = cfg.stars.names;
|
|
231
|
+
if (has(cfg.stars, "namelimit")) res.stars.designationLimit = cfg.stars.namelimit;
|
|
232
|
+
if (has(cfg.stars, "namestyle")) Object.assign(res.stars.designationStyle, cfg.stars.namestyle);
|
|
233
|
+
// proper -> propername
|
|
234
|
+
if (has(cfg.stars, "proper")) res.stars.propername = cfg.stars.proper;
|
|
235
|
+
if (has(cfg.stars, "propernamelimit")) res.stars.propernameLimit = cfg.stars.propernamelimit;
|
|
236
|
+
if (has(cfg.stars, "propernamestyle")) Object.assign(res.stars.propernameStyle, cfg.stars.propernamestyle);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (has(cfg, "dsos")) {
|
|
240
|
+
// names, desig -> namesType
|
|
241
|
+
//if (has(cfg.dsos, "names") && cfg.dsos.names === true) res.dsos.namesType = "name";
|
|
242
|
+
if (has(cfg.dsos, "desig") && cfg.dsos.desig === true) res.dsos.namesType = "desig";
|
|
243
|
+
if (has(cfg.dsos, "namelimit")) res.dsos.nameLimit = cfg.dsos.namelimit;
|
|
244
|
+
if (has(cfg.dsos, "namestyle")) Object.assign(res.dsos.nameStyle, cfg.dsos.namestyle);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (has(cfg, "constellations")) {
|
|
248
|
+
// names, desig -> namesType
|
|
249
|
+
if (has(cfg.constellations, "show") && cfg.constellations.show === true) res.constellations.names = true;
|
|
250
|
+
//if (has(cfg.constellations, "names") && cfg.constellations.names === true) res.constellations.namesType = "name";
|
|
251
|
+
if (has(cfg.constellations, "desig") && cfg.constellations.desig === true) res.constellations.namesType = "desig";
|
|
252
|
+
if (res.constellations.namesType === "latin") res.constellations.namesType = "la";
|
|
253
|
+
if (res.constellations.namesType === "iau") res.constellations.namesType = "name";
|
|
254
|
+
if (has(cfg.constellations, "namestyle")) Object.assign(res.constellations.nameStyle, cfg.constellations.namestyle);
|
|
255
|
+
if (has(cfg.constellations, "linestyle")) Object.assign(res.constellations.lineStyle, cfg.constellations.linestyle);
|
|
256
|
+
if (has(cfg.constellations, "boundstyle")) Object.assign(res.constellations.boundStyle, cfg.constellations.boundstyle);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (has(cfg, "planets")) {
|
|
260
|
+
if (has(cfg.planets, "style")) Object.assign(res.planets.style, cfg.planets.symbolStyle);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//Assign default name types if none given
|
|
264
|
+
if (!res.stars.designationType || res.stars.designationType === "") res.stars.designationType = "desig";
|
|
265
|
+
if (!has(formats.starnames[res.culture].designation, res.stars.designationType)) res.designationType = "desig";
|
|
266
|
+
if (!res.stars.propernameType || res.stars.propernameType === "") res.stars.propernameType = "name";
|
|
267
|
+
if (!has(formats.starnames[res.culture].propername, res.stars.propernameType)) res.propernameType = "name";
|
|
268
|
+
if (!res.dsos.namesType || res.dsos.namesType === "") res.dsos.namesType = "desig";
|
|
269
|
+
if (!res.constellations.namesType || res.constellations.namesType === "") res.constellations.namesType = "desig";
|
|
270
|
+
if (!has(formats.constellations[res.culture].names, res.constellations.namesType)) res.constellations.namesType = "name";
|
|
271
|
+
if (!res.planets.symbolType || res.planets.symbolType === "") res.planets.symbolType = "symbol";
|
|
272
|
+
if (!res.planets.namesType || res.planets.namesType === "") res.planets.namesType = "desig";
|
|
273
|
+
if (!has(formats.planets[res.culture].names, res.planets.namesType)) res.planets.namesType = "desig";
|
|
274
|
+
//Expand all parameters that can be arrays into arrays, no need to test it later
|
|
275
|
+
res.constellations.nameStyle.font = arrayfy(res.constellations.nameStyle.font);
|
|
276
|
+
res.constellations.nameStyle.opacity = arrayfy(res.constellations.nameStyle.opacity);
|
|
277
|
+
res.constellations.nameStyle.fill = arrayfy(res.constellations.nameStyle.fill);
|
|
278
|
+
res.constellations.lineStyle.width = arrayfy(res.constellations.lineStyle.width);
|
|
279
|
+
res.constellations.lineStyle.opacity = arrayfy(res.constellations.lineStyle.opacity);
|
|
280
|
+
res.constellations.lineStyle.stroke = arrayfy(res.constellations.lineStyle.stroke);
|
|
281
|
+
|
|
282
|
+
if (!base) Object.assign(globalConfig, res);
|
|
283
|
+
return res;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
function arrayfy(o) {
|
|
288
|
+
var res;
|
|
289
|
+
if (!isArray(o)) return [o, o, o]; //It saves some work later, OK?
|
|
290
|
+
if (o.length >= 3) return o;
|
|
291
|
+
if (o.length === 1) return [o[0], o[0], o[0]];
|
|
292
|
+
if (o.length === 2) return [o[0], o[1], o[1]];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
Celestial.settings = function () { return settings; };
|
|
296
|
+
|
|
297
|
+
//b-v color index to rgb color value scale
|
|
298
|
+
// The v3 quantize scale coped with a descending domain; v4+ runs bisect over
|
|
299
|
+
// the thresholds, which is only correct in ascending order — with the domain
|
|
300
|
+
// [3.347, -0.335] every star turned red. An ascending domain with a reversed
|
|
301
|
+
// range gives the same mapping. svg.js's star-colour loop uses the two ends of
|
|
302
|
+
// domain(), so the order dependence had to be removed there separately —
|
|
303
|
+
// otherwise the reversal would stop that loop from running at all.
|
|
304
|
+
var bvcolor = d3.scaleQuantize().domain([-0.335, 3.347]) //main sequence <= 1.7
|
|
305
|
+
.range([ '#ff4700', '#ff4b00', '#ff4f00', '#ff5300', '#ff5600', '#ff5900', '#ff5b00', '#ff5d00', '#ff6000', '#ff6300', '#ff6500', '#ff6700', '#ff6900', '#ff6b00', '#ff6d00', '#ff7000', '#ff7300', '#ff7500', '#ff7800', '#ff7a00', '#ff7c00', '#ff7e00', '#ff8100', '#ff8300', '#ff8506', '#ff870a', '#ff8912', '#ff8b1a', '#ff8e21', '#ff9127', '#ff932c', '#ff9631', '#ff9836', '#ff9a3c', '#ff9d3f', '#ffa148', '#ffa34b', '#ffa54f', '#ffa753', '#ffa957', '#ffab5a', '#ffad5e', '#ffb165', '#ffb269', '#ffb46b', '#ffb872', '#ffb975', '#ffbb78', '#ffbe7e', '#ffc184', '#ffc489', '#ffc78f', '#ffc892', '#ffc994', '#ffcc99', '#ffce9f', '#ffd1a3', '#ffd3a8', '#ffd5ad', '#ffd7b1', '#ffd9b6', '#ffdbba', '#ffddbe', '#ffdfc2', '#ffe1c6', '#ffe3ca', '#ffe4ce', '#ffe8d5', '#ffe9d9', '#ffebdc', '#ffece0', '#ffefe6', '#fff0e9', '#fff2ec', '#fff4f2', '#fff5f5', '#fff6f8', '#fff9fd', '#fef9ff', '#f9f6ff', '#f6f4ff', '#f3f2ff', '#eff0ff', '#ebeeff', '#e9edff', '#e6ebff', '#e3e9ff', '#e0e7ff', '#dee6ff', '#dce5ff', '#d9e3ff', '#d7e2ff', '#d3e0ff', '#c9d9ff', '#bfd3ff', '#b7ceff', '#afc9ff', '#a9c5ff', '#a4c2ff', '#9fbfff', '#9bbcff'].reverse());
|
|
306
|
+
|
|
307
|
+
/* Default parameters for each supported projection
|
|
308
|
+
arg: constructor argument, if any
|
|
309
|
+
scale: scale parameter so that they all have ~equal width, normalized to 1024 pixels
|
|
310
|
+
ratio: width/height ratio, 2.0 if none
|
|
311
|
+
clip: projection clipped to 90 degrees from center, otherwise to antimeridian
|
|
312
|
+
*/
|
|
313
|
+
var projections = {
|
|
314
|
+
"airy": {n:"Airy’s Minimum Error", arg:Math.PI/2, scale:360, ratio:1.0, clip:true},
|
|
315
|
+
"aitoff": {n:"Aitoff", arg:null, scale:162},
|
|
316
|
+
"armadillo": {n:"Armadillo", arg:0, scale:250},
|
|
317
|
+
"august": {n:"August", arg:null, scale:94, ratio:1.4},
|
|
318
|
+
"azimuthalEqualArea": {n:"Azimuthal Equal Area", arg:null, scale:340, ratio:1.0, clip:true},
|
|
319
|
+
"azimuthalEquidistant": {n:"Azimuthal Equidistant", arg:null, scale:320, ratio:1.0, clip:true},
|
|
320
|
+
"baker": {n:"Baker Dinomic", arg:null, scale:160, ratio:1.4},
|
|
321
|
+
"berghaus": {n:"Berghaus Star", arg:0, scale:320, ratio:1.0, clip:true},
|
|
322
|
+
"boggs": {n:"Boggs Eumorphic", arg:null, scale:170},
|
|
323
|
+
"bonne": {n:"Bonne", arg:Math.PI/2.5, scale:225, ratio:0.88},
|
|
324
|
+
"bromley": {n:"Bromley", arg:null, scale:162},
|
|
325
|
+
// "butterfly": {n:"Butterfly", arg:null, scale:31, ratio:1.1, clip:true},
|
|
326
|
+
"cassini": {n:"Cassini", arg:null, scale:325, ratio:1.0, clip:true},
|
|
327
|
+
"collignon": {n:"Collignon", arg:null, scale:100, ratio:2.6},
|
|
328
|
+
"craig": {n:"Craig Retroazimuthal", arg:0, scale:310, ratio:1.5, clip:true},
|
|
329
|
+
"craster": {n:"Craster Parabolic", arg:null, scale:160},
|
|
330
|
+
"cylindricalEqualArea": {n:"Cylindrical Equal Area", arg:Math.PI/6, scale:190, ratio:2.3},
|
|
331
|
+
"cylindricalStereographic": {n:"Cylindrical Stereographic", arg:Math.PI/4, scale:230, ratio:1.3},
|
|
332
|
+
"eckert1": {n:"Eckert I", arg:null, scale:175},
|
|
333
|
+
"eckert2": {n:"Eckert II", arg:null, scale:175},
|
|
334
|
+
"eckert3": {n:"Eckert III", arg:null, scale:190},
|
|
335
|
+
"eckert4": {n:"Eckert IV", arg:null, scale:190},
|
|
336
|
+
"eckert5": {n:"Eckert V", arg:null, scale:182},
|
|
337
|
+
"eckert6": {n:"Eckert VI", arg:null, scale:182},
|
|
338
|
+
"eisenlohr": {n:"Eisenlohr", arg:null, scale:102},
|
|
339
|
+
"equirectangular": {n:"Equirectangular", arg:null, scale:165},
|
|
340
|
+
"fahey": {n:"Fahey", arg:null, scale:196, ratio:1.4},
|
|
341
|
+
"mtFlatPolarParabolic": {n:"Flat Polar Parabolic", arg:null, scale:175},
|
|
342
|
+
"mtFlatPolarQuartic": {n:"Flat Polar Quartic", arg:null, scale:230, ratio:1.65},
|
|
343
|
+
"mtFlatPolarSinusoidal": {n:"Flat Polar Sinusoidal", arg:null, scale:175, ratio:1.9},
|
|
344
|
+
"foucaut": {n:"Foucaut", arg:null, scale:142},
|
|
345
|
+
"ginzburg4": {n:"Ginzburg IV", arg:null, scale:180, ratio:1.7},
|
|
346
|
+
"ginzburg5": {n:"Ginzburg V", arg:null, scale:196, ratio:1.55},
|
|
347
|
+
"ginzburg6": {n:"Ginzburg VI", arg:null, scale:190, ratio:1.4},
|
|
348
|
+
"ginzburg8": {n:"Ginzburg VIII", arg:null, scale:205, ratio:1.3},
|
|
349
|
+
"ginzburg9": {n:"Ginzburg IX", arg:null, scale:190, ratio:1.4},
|
|
350
|
+
//"guyou": {n:"Guyou", arg:null, scale:160, ratio:2, clip:true},
|
|
351
|
+
//"bonne": {n:"Heart", arg:Math.PI/2.5, scale:225, ratio:0.88},
|
|
352
|
+
"homolosine": {n:"Goode Homolosine", arg:null, scale:160, ratio:2.2},
|
|
353
|
+
"hammer": {n:"Hammer", arg:2, scale:180},
|
|
354
|
+
"hatano": {n:"Hatano", arg:null, scale:186},
|
|
355
|
+
"healpix": {n:"HEALPix", arg:1, scale:320, ratio:1.2},
|
|
356
|
+
"hill": {n:"Hill Eucyclic", arg:2, scale:190, ratio:1.1},
|
|
357
|
+
"kavrayskiy7": {n:"Kavrayskiy VII", arg:null, scale:185, ratio:1.75},
|
|
358
|
+
"lagrange": {n:"Lagrange", arg:Math.PI/4, scale:88, ratio:1.6, clip:false},
|
|
359
|
+
"larrivee": {n:"l'Arrivée", arg:null, scale:160, ratio:1.25},
|
|
360
|
+
"laskowski": {n:"Laskowski Tri-Optimal", arg:null, scale:165, ratio:1.7},
|
|
361
|
+
"loximuthal": {n:"Loximuthal", arg:Math.PI/4, scale:175, ratio:1.8},
|
|
362
|
+
"mercator": {n:"Mercator", arg:null, scale:160, ratio:1.3},
|
|
363
|
+
"miller": {n:"Miller", arg:null, scale:160, ratio:1.5},
|
|
364
|
+
"mollweide": {n:"Mollweide", arg:null, scale:180},
|
|
365
|
+
"naturalEarth": {n:"Natural Earth", arg:null, scale:185, ratio:1.85},
|
|
366
|
+
"nellHammer": {n:"Nell Hammer", arg:null, scale:160, ratio:2.6},
|
|
367
|
+
"orthographic": {n:"Orthographic", arg:null, scale:480, ratio:1.0, clip:true},
|
|
368
|
+
"patterson": {n:"Patterson Cylindrical", arg:null, scale:160, ratio:1.75},
|
|
369
|
+
"polyconic": {n:"Polyconic", arg:null, scale:160, ratio:1.3},
|
|
370
|
+
"quincuncial": {n:"Quincuncial", arg:null, scale:160, ratio:1.3},
|
|
371
|
+
"rectangularPolyconic": {n:"Rectangular Polyconic", arg:0, scale:160, ratio:1.65},
|
|
372
|
+
"robinson": {n:"Robinson", arg:null, scale:160},
|
|
373
|
+
"sinusoidal": {n:"Sinusoidal", arg:null, scale:160, ratio:2},
|
|
374
|
+
"stereographic": {n:"Stereographic", arg:null, scale:500, ratio:1.0, clip:true},
|
|
375
|
+
"times": {n:"Times", arg:null, scale:210, ratio:1.4},
|
|
376
|
+
"twoPointEquidistant": {n:"Two-Point Equidistant", arg:Math.PI/2, scale:320, ratio:1.15, clip:true},
|
|
377
|
+
"vanDerGrinten": {n:"van Der Grinten", arg:null, scale:160, ratio:1.0},
|
|
378
|
+
"vanDerGrinten2": {n:"van Der Grinten II", arg:null, scale:160, ratio:1.0},
|
|
379
|
+
"vanDerGrinten3": {n:"van Der Grinten III", arg:null, scale:160, ratio:1.0},
|
|
380
|
+
"vanDerGrinten4": {n:"van Der Grinten IV", arg:null, scale:160, ratio:1.6},
|
|
381
|
+
"wagner4": {n:"Wagner IV", arg:null, scale:185},
|
|
382
|
+
"wagner6": {n:"Wagner VI", arg:null, scale:160},
|
|
383
|
+
"wagner7": {n:"Wagner VII", arg:null, scale:190, ratio:1.8},
|
|
384
|
+
"wiechel": {n:"Wiechel", arg:null, scale:360, ratio:1.0, clip:true},
|
|
385
|
+
"winkel3": {n:"Winkel Tripel", arg:null, scale:196, ratio:1.7}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
Celestial.projections = function () { return projections; };
|
|
389
|
+
|
|
390
|
+
var formats = {
|
|
391
|
+
"starnames": {
|
|
392
|
+
// "name":"","bayer":"","flam":"","var":"","gl":"","hd":"","c":"","desig":""
|
|
393
|
+
"iau": {
|
|
394
|
+
"designation": {
|
|
395
|
+
"desig": "Designation",
|
|
396
|
+
"bayer": "Bayer",
|
|
397
|
+
"flam": "Flamsteed",
|
|
398
|
+
"var": "Variable",
|
|
399
|
+
"gl": "Gliese",
|
|
400
|
+
"hd": "Draper",
|
|
401
|
+
"hip": "Hipparcos"},
|
|
402
|
+
"propername": {
|
|
403
|
+
"name": "IAU Name",
|
|
404
|
+
"ar": "Arabic",
|
|
405
|
+
"zh": "Chinese",
|
|
406
|
+
"en": "English",
|
|
407
|
+
"fi": "Finnish",
|
|
408
|
+
"fr": "French",
|
|
409
|
+
"de": "German",
|
|
410
|
+
"el": "Greek",
|
|
411
|
+
"he": "Hebrew",
|
|
412
|
+
"hi": "Hindi",
|
|
413
|
+
"it": "Italian",
|
|
414
|
+
"ja": "Japanese",
|
|
415
|
+
"ko": "Korean",
|
|
416
|
+
"la": "Latin",
|
|
417
|
+
"fa": "Persian",
|
|
418
|
+
"ru": "Russian",
|
|
419
|
+
"es": "Spanish",
|
|
420
|
+
"tr": "Turkish"}
|
|
421
|
+
},
|
|
422
|
+
"cn": {
|
|
423
|
+
"propername": {
|
|
424
|
+
"name": "Proper name",
|
|
425
|
+
"en": "English",
|
|
426
|
+
"pinyin": "Pinyin"},
|
|
427
|
+
"designation": {
|
|
428
|
+
"desig": "IAU Designation"}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
"constellations": {
|
|
432
|
+
"iau": {
|
|
433
|
+
"names": {
|
|
434
|
+
"desig": "Designation",
|
|
435
|
+
"name": "IAU Name",
|
|
436
|
+
"ar": "Arabic",
|
|
437
|
+
"zh": "Chinese",
|
|
438
|
+
"cz": "Czech",
|
|
439
|
+
"en": "English",
|
|
440
|
+
"ee": "Estonian",
|
|
441
|
+
"fi": "Finnish",
|
|
442
|
+
"fr": "French",
|
|
443
|
+
"de": "German",
|
|
444
|
+
"el": "Greek",
|
|
445
|
+
"he": "Hebrew",
|
|
446
|
+
"hi": "Hindi",
|
|
447
|
+
"it": "Italian",
|
|
448
|
+
"ja": "Japanese",
|
|
449
|
+
"sw": "Kiswahili",
|
|
450
|
+
"ko": "Korean",
|
|
451
|
+
"la": "Latin",
|
|
452
|
+
"fa": "Persian",
|
|
453
|
+
"ru": "Russian",
|
|
454
|
+
"es": "Spanish",
|
|
455
|
+
"tr": "Turkish"}
|
|
456
|
+
},
|
|
457
|
+
"cn": {
|
|
458
|
+
"names": {
|
|
459
|
+
"name": "Proper name",
|
|
460
|
+
"en": "English",
|
|
461
|
+
"pinyin": "Pinyin"}
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
"planets": {
|
|
465
|
+
"iau": {
|
|
466
|
+
"symbol": {
|
|
467
|
+
"symbol": "\u263e Symbol",
|
|
468
|
+
"letter": "\u216c Letter",
|
|
469
|
+
"disk": "\u25cf Disk"},
|
|
470
|
+
"names": {
|
|
471
|
+
"desig": "Designation",
|
|
472
|
+
"ar": "Arabic",
|
|
473
|
+
"zh": "Chinese",
|
|
474
|
+
"en": "English",
|
|
475
|
+
"fr": "French",
|
|
476
|
+
"de": "German",
|
|
477
|
+
"el": "Greek",
|
|
478
|
+
"he": "Hebrew",
|
|
479
|
+
"hi": "Hindi",
|
|
480
|
+
"it": "Italian",
|
|
481
|
+
"ja": "Japanese",
|
|
482
|
+
"ko": "Korean",
|
|
483
|
+
"la": "Latin",
|
|
484
|
+
"fa": "Persian",
|
|
485
|
+
"ru": "Russian",
|
|
486
|
+
"es": "Spanish"}
|
|
487
|
+
},
|
|
488
|
+
"cn": {
|
|
489
|
+
"symbol": {
|
|
490
|
+
"symbol": "\u263e Symbol",
|
|
491
|
+
"letter": "\u216c Letter",
|
|
492
|
+
"disk": "\u25cf Disk"},
|
|
493
|
+
"names": {
|
|
494
|
+
"desig": "Designation",
|
|
495
|
+
"name": "Chinese",
|
|
496
|
+
"pinyin": "Pinyin",
|
|
497
|
+
"en": "English"}
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
"dsonames": {
|
|
501
|
+
"iau": {
|
|
502
|
+
"names": {
|
|
503
|
+
"desig": "Designation",
|
|
504
|
+
"name": "English",
|
|
505
|
+
"ar": "Arabic",
|
|
506
|
+
"zh": "Chinese",
|
|
507
|
+
"fi": "Finnish",
|
|
508
|
+
"fr": "French",
|
|
509
|
+
"de": "German",
|
|
510
|
+
"el": "Greek",
|
|
511
|
+
//"he": "Hebrew",
|
|
512
|
+
"hi": "Hindi",
|
|
513
|
+
"it": "Italian",
|
|
514
|
+
"ja": "Japanese",
|
|
515
|
+
"ko": "Korean",
|
|
516
|
+
"la": "Latin",
|
|
517
|
+
"fa": "Persian",
|
|
518
|
+
"ru": "Russian",
|
|
519
|
+
"es": "Spanish",
|
|
520
|
+
"tr": "Turkish"}
|
|
521
|
+
},
|
|
522
|
+
"cn": {
|
|
523
|
+
"names": {
|
|
524
|
+
"desig": "Designation",
|
|
525
|
+
"name": "Chinese",
|
|
526
|
+
"pinyin": "Pinyin",
|
|
527
|
+
"en": "English"}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
var formats_all = {
|
|
533
|
+
"iau": Object.keys(formats.constellations.iau.names).concat(Object.keys(formats.planets.iau.names)).filter( function(value, index, self) { return self.indexOf(value) === index; } ),
|
|
534
|
+
"cn": Object.keys(formats.constellations.cn.names).concat(Object.keys(formats.starnames.cn.propername)).filter( function(value, index, self) { return self.indexOf(value) === index; } )
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
export { arrayfy, bvcolor, formats, formats_all, globalConfig, projections, settings };
|
package/src/core.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The library's central object.
|
|
2
|
+
//
|
|
3
|
+
// It lives in its own module rather than in celestial.js because nearly every
|
|
4
|
+
// module refers to it — several of them already at load time (for example
|
|
5
|
+
// `Celestial.settings = ...`). The module graph is circular
|
|
6
|
+
// (celestial <-> config <-> form <-> svg), and in a cycle what matters is which
|
|
7
|
+
// module is evaluated first. This file imports nothing, so it always runs
|
|
8
|
+
// first, and by the time anyone touches the object it already exists.
|
|
9
|
+
export var Celestial = {
|
|
10
|
+
// Must match the package version — guarded by test/package.test.mjs.
|
|
11
|
+
version: '0.8.0',
|
|
12
|
+
container: null,
|
|
13
|
+
data: []
|
|
14
|
+
};
|
package/src/d3.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Only the D3 functions the library actually uses.
|
|
2
|
+
//
|
|
3
|
+
// Why this shape: the call sites stay in `d3.geoPath()` form, so modularisation
|
|
4
|
+
// did not have to rewrite every line of the code — yet the bundler pulls in
|
|
5
|
+
// exactly what is listed here instead of the whole `d3` package. This is also
|
|
6
|
+
// what removes the need for a global `d3` (upstream #134, "d3 is not defined").
|
|
7
|
+
//
|
|
8
|
+
// The projections' raw functions are deliberately NOT here: projection.js
|
|
9
|
+
// resolves those by name, so it imports the two packages as namespaces.
|
|
10
|
+
export { select, selectAll, pointer } from "d3-selection";
|
|
11
|
+
export { json } from "d3-fetch";
|
|
12
|
+
export {
|
|
13
|
+
geoPath, geoProjection, geoCircle, geoGraticule,
|
|
14
|
+
geoDistance, geoInterpolate, geoRotation, geoArea, geoContains
|
|
15
|
+
} from "d3-geo";
|
|
16
|
+
export { interpolateNumber, interpolateLab } from "d3-interpolate";
|
|
17
|
+
export { scaleQuantize } from "d3-scale";
|
|
18
|
+
export { timeFormat, timeParse } from "d3-time-format";
|
|
19
|
+
export {
|
|
20
|
+
symbol, symbolCircle, symbolCross, symbolDiamond,
|
|
21
|
+
symbolSquare, symbolStar, symbolTriangle, symbolWye
|
|
22
|
+
} from "d3-shape";
|
|
23
|
+
export { zoom, zoomIdentity } from "d3-zoom";
|
|
24
|
+
export { dispatch } from "d3-dispatch";
|
|
25
|
+
|
|
26
|
+
// Imported for its side effect: d3-transition is what adds the .transition()
|
|
27
|
+
// method to the selection prototype, which celestial.js's animations use.
|
|
28
|
+
import "d3-transition";
|