如何定义未定义的变量[关闭]

问题描述 投票:0回答:0

我正在尝试使用 Stellarium 应用程序自动拍摄数百张不同星座的照片,而不会显示网格、艺术或其他星星。然后我试图将这些屏幕截图发送到保管箱或 googledrive 以存储图片。每次运行此代码时,我都会发现某些内容未定义。我将如何定义未定义的变量?

require("i18n.inc");

const core = StelApp.getCore();
core.clear("starchart");
GridLinesMgr.setFlagEquatorGrid(false);
NebulaMgr.setFlagHints(false);
var constellations = ConstellationMgr.getConstellationsEnglishNames();
ConstellationMgr.setFlagArt(false);
ConstellationMgr.setFlagBoundaries(false);
ConstellationMgr.setFlagLines(false);
ConstellationMgr.setFlagLabels(false);
core.setGuiVisible(false);
var id = LabelMgr.labelScreen(tr("Press Ctrl+T to un-hide the toolbar"), 100,100, false, 20);
LabelMgr.setLabelShow(id, true);
core.wait(4);
LabelMgr.setLabelShow(id, false);
LabelMgr.deleteLabel(id);

// Loop through each constellation and take a screenshot
for (i=0; i<constellations.length; i++)
{
objName = constellations[i];
core.selectConstellationByName(objName);
StelMovementMgr.autoZoomIn(6);
core.wait(1);
core.setObserverLocation(
8 + 36/60 + 25.85/60/60, // core.dmsToRad( 8, 36, 25.85 ), // longitude
47 + 32/60 + 21.48/60/60, // core.dmsToRad(47, 32, 21.48 ), // latitude
0,
0,
"", // or "Irchelturm",
"Earth"
);

// Set date and time of observation
core.setDate(
'2020-10-10T21:30:00',
'local', // or 'utc'
true // enable Delta T correction
);

StelMovementMgr.zoomTo(25, 0.01);
core.wait(0.01); // Why, oh why is this necessary?
core.moveToRaDec(22.43719, 5.925423);

// Take screenshot
var screenshotFilename = 'screenshot-' + objName + '.png';
core.screenshot(
screenshotFilename, // filename
false, // invert
'.', // directory (current directory)
true, // overwrite
'png' // format
);

// Upload screenshot to Dropbox
const fetch = require('node-fetch');
const fs = require('fs');

// Define Dropbox API endpoint and access token
const dropboxUploadEndpoint = 'https://content.dropboxapi.com/2/files/upload';
const accessToken = '<YOUR_DROPBOX_ACCESS_TOKEN>';

// Read screenshot file data
const fileData = fs.readFileSync(screenshotFilename);

// Define Dropbox API headers and payload
const headers = {
'Authorization': 'Bearer ' + accessToken,
'Content-Type': 'application/octet-stream',
'Dropbox-API-Arg': JSON.stringify({
'path': '/' + screenshotFilename,
'mode': 'add',
'autorename': true,
'mute': false
})
};

// Upload screenshot file to Dropbox
}
ReferenceError: StelApp is not defined
    at Object.<anonymous> 


javascript referenceerror stellarium
© www.soinside.com 2019 - 2024. All rights reserved.