Branch data Line data Source code
1 [ + ]: 1 : /**
2 : 1 : * @module weather
3 : 1 : * @desc A module that defines a Weather class to fetch and manipulate weather data using the Visual Crossing Weather API.
4 : 1 : * @version 1.0.0
5 : 1 : * @author Essam A. El-Sherif
6 : 1 : */
7 : 1 :
8 : 1 : /* Import node.js core modules */
9 : 1 : import https from 'node:https';
10 : 1 :
11 : 1 : /* Import local dependencies */
12 : 1 : import { extractSubobjectByKeys, updateObject, isValidObject } from './utils.js';
13 : 1 :
14 : 1 : /**
15 : 1 : * @const {string} BASE_URL - Base URL for creating a weather API request.
16 : 1 : * @see [Visual Crossing Timeline Weather API]{@link https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/#request-base-url}.
17 : 1 : */
18 : 1 : const BASE_URL = 'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline';
19 : 1 :
20 : 1 : /**
21 : 1 : * @class Weather
22 : 1 : * @static
23 : 1 : * @desc A class to fetch and manipulate weather data using the Visual Crossing Weather API.
24 : 1 : */
25 [ + ]: 1 : export class Weather{
26 : 83 :
27 : 83 : /**
28 : 83 : * @member weatherData
29 : 83 : * @instance
30 : 83 : * @memberof module:weather.Weather
31 : 83 : * @private
32 : 83 : * @desc Private member to hold the weather data object.
33 : 83 : */
34 : 83 : #weatherData;
35 : 83 :
36 : 83 : /**
37 : 83 : * @method constructor
38 : 83 : * @instance
39 : 83 : * @memberof module:weather.Weather
40 : 83 : * @param {string} apiKey - API key for the weather API.
41 : 83 : * @param {string} baseUrl - Base URL of the weather API.
42 : 83 : * @desc Constructs a new Weather object.
43 : 83 : */
44 [ + ]: 83 : constructor(apiKey = '', baseUrl = BASE_URL){
45 : 83 : this.apiKey = apiKey;
46 : 83 : this.baseUrl = baseUrl;
47 : 83 : this.#weatherData = {};
48 : 83 :
49 : 83 : /* Hide the apiKey property */
50 : 83 : Object.defineProperty(this, 'apiKey', {enumerable: false});
51 : 83 : }
52 : 83 :
53 : 83 : /**
54 : 83 : * @method filterItemByDatetimeVal
55 : 83 : * @static
56 : 83 : * @memberof module:weather.Weather
57 : 83 : * @param {Array} src - The source list of dictionaries, each expected to contain a 'datetime' key.
58 : 83 : * @param {string|number} datetimeVal - The datetime value used for filtering, which can be a date string or an index.
59 : 83 : * @returns {Object|null} The filtered dictionary item, or null if not available.
60 : 83 : * @desc Filters an item by its datetime value from a list of dictionaries, each containing a 'datetime' key.
61 : 83 : * @throws {TypeError} If the datetimeVal is neither a string nor a number.
62 : 83 : */
63 [ + ]: 83 : static filterItemByDatetimeVal(src, datetimeVal){
64 : 416 :
65 [ + ]: 416 : if(typeof datetimeVal === 'string'){
66 [ + ][ + ]: 156 : return src.find(item => item.datetime === datetimeVal) || null;
67 [ + ]: 156 : }
68 : 260 : else
69 [ + ]: 260 : if(typeof datetimeVal === 'number'){
70 [ - ]: 160 : return src[datetimeVal] || null;
71 [ + ]: 160 : }
72 : 100 : else{
73 : 100 : throw new TypeError(`Weather.filterItemByDatetimeVal: Invalid input datetime value '${datetimeVal}'.`);
74 : 100 : }
75 : 416 : }
76 : 83 :
77 : 83 : /**
78 : 83 : * @method setItemByDatetimeVal
79 : 83 : * @static
80 : 83 : * @memberof module:weather.Weather
81 : 83 : * @param {Array} src - The source list of dictionaries, each expected to contain a 'datetime' key.
82 : 83 : * @param {string|number} datetimeVal - The datetime value used for updating, which can be a date string or an index.
83 : 83 : * @param {Object} data - The new data dictionary to replace the old dictionary.
84 : 83 : * @desc Sets an item's data by its datetime value in a list of dictionaries based on the given datetimeVal.
85 : 83 : * @throws {TypeError} If the input data is not an object or datetimeVal is neither a string nor a number.
86 : 83 : */
87 [ + ]: 83 : static setItemByDatetimeVal(src, datetimeVal, data){
88 : 5 :
89 [ + ][ + ]: 5 : if(typeof data !== 'object' || data === null){
90 : 1 : throw new TypeError(`Weather.setItemByDatetimeVal: Invalid input data value '${data}'.`);
91 [ + ]: 1 : }
92 : 4 :
93 [ + ]: 5 : if(typeof datetimeVal === 'string'){
94 : 2 : for(const item of src){
95 : 2 : if(item.datetime === datetimeVal){
96 : 2 : Object.assign(item, data, { datetime: datetimeVal });
97 : 2 : break;
98 : 2 : }
99 : 2 : }
100 : 2 : }
101 : 2 : else
102 [ + ]: 2 : if(typeof datetimeVal === 'number'){
103 : 1 : if(src[datetimeVal]){
104 : 1 : data.datetime = src[datetimeVal].datetime;
105 : 1 : src[datetimeVal] = { ...data };
106 : 1 : }
107 : 1 : }
108 : 1 : else{
109 : 1 : throw new TypeError(`Weather.setItemByDatetimeVal: Invalid input datetime value '${datetimeVal}'.`);
110 : 1 : }
111 : 5 : }
112 : 83 :
113 : 83 : /**
114 : 83 : * @method updateItemByDatetimeVal
115 : 83 : * @static
116 : 83 : * @memberof module:weather.Weather
117 : 83 : * @param {Array} src - The source list of dictionaries, each expected to contain a 'datetime' key.
118 : 83 : * @param {string|number} datetimeVal - The datetime value used for updating, which can be a date string or an index.
119 : 83 : * @param {Object} data - The new data dictionary to update the old dictionary.
120 : 83 : * @desc Updates an item's data by its datetime value in a list of dictionaries based on the given datetimeVal.
121 : 83 : * @throws {TypeError} If the input data is not an object or datetimeVal is neither a string nor a number.
122 : 83 : */
123 [ + ]: 83 : static updateItemByDatetimeVal(src, datetimeVal, data){
124 : 5 :
125 [ + ][ + ]: 5 : if(typeof data !== 'object' || data === null){
126 : 1 : throw new TypeError(`Weather.updateItemByDatetimeVal: Invalid input data value '${data}'.`);
127 [ + ]: 1 : }
128 : 4 :
129 [ + ]: 5 : if(typeof datetimeVal === 'string'){
130 : 2 : for(const item of src){
131 : 2 : if(item.datetime === datetimeVal){
132 : 2 : Object.assign(item, data);
133 : 2 : item.datetime = datetimeVal;
134 : 2 : break;
135 : 2 : }
136 : 2 : }
137 : 2 : }
138 : 2 : else
139 [ + ]: 2 : if(typeof datetimeVal === 'number'){
140 : 1 : if(src[datetimeVal]){
141 : 1 : data.datetime = src[datetimeVal].datetime;
142 : 1 : Object.assign(src[datetimeVal], data);
143 : 1 : }
144 : 1 : }
145 : 1 : else{
146 : 1 : throw new TypeError(`Weather.updateItemByDatetimeVal: Invalid input datetime value '${datetimeVal}'.`);
147 : 1 : }
148 : 5 : }
149 : 83 :
150 : 83 : /**
151 : 83 : * @method validateParamDate
152 : 83 : * @static
153 : 83 : * @memberof module:weather.Weather
154 : 83 : * @param {string|number} param - The date for which to retrieve weather data.
155 : 83 : * @returns {string|number} The validated date for which to retrieve weather data.
156 : 83 : * @desc Validate and return the date for which to retrieve weather data.
157 : 83 : * @throws {TypeError|Error} If the input data type is neither a string nor a number or its format is invalid.
158 : 83 : */
159 [ + ]: 83 : static validateParamDate(param){
160 [ + ]: 20 : if(typeof param === 'string'){
161 : 18 : // using dynamaic dates to replace date1 and date2 parameters
162 : 18 : if(
163 : 18 : [
164 : 18 : 'today', // from midnight today to midnight tomorrow at the requested location.
165 : 18 : 'tomorrow', // from midnight tomorrow to midnight the day after at the requested location.
166 : 18 : 'yesterday', // from midnight to midnight on yesterday’s date.
167 : 18 : 'yeartodate', // from midnight of January 1st of the current year until the current date time.
168 : 18 : 'monthtodate', // from midnight on the 1st of the current month until the current date time.
169 : 18 : 'lastyear', // the one year period ending on yesterday’s date.
170 : 18 : 'last24hours', // the 24 hour period ending at the current time (rounded to the currenthour).
171 : 18 : 'nextweekend', // the next occurrence of the weekend after today’s day. Weekend is defined as Saturday and Sunday.
172 : 18 : 'lastweekend', // the last occurrence of the weekend before today’s day. Weekend is defined as Saturday and Sunday.
173 : 18 :
174 [ + ]: 18 : ].includes(param) ||
175 : 9 :
176 [ + ]: 18 : /^next(\d+)days$/.test(param) ||
177 [ + ]: 18 : /^last(\d+)days$/.test(param) ||
178 : 7 :
179 [ + ]: 18 : /^next(saturday|sunday|monday|tuesday|wednesday|thursday|friday)$/.test(param) ||
180 : 6 : /^last(saturday|sunday|monday|tuesday|wednesday|thursday|friday)$/.test(param)
181 [ + ]: 18 : ){
182 : 13 : return param;
183 [ + ]: 13 : }
184 : 5 : else
185 : 5 : // using date format for date1 or date1 and date2
186 [ + ]: 5 : if(/^\d{4,4}\-\d{2,2}\-\d{2,2}$/.test(param)){
187 : 1 : return param;
188 [ + ]: 1 : }
189 : 4 : else
190 : 4 : // using datetime format
191 [ + ]: 4 : if(/^\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d$/.test(param)){
192 : 1 : return param;
193 [ + ]: 1 : }
194 : 3 : else{
195 : 3 : throw new Error(`Weather.validateParamDate: Invalid date '${param}'.`);
196 : 3 : }
197 [ + ]: 18 : }
198 : 2 : else
199 [ + ]: 2 : if(typeof param === 'number'){
200 : 1 : return param;
201 : 1 : }
202 : 1 : else{
203 : 1 : throw new TypeError(`Weather.validateParamDate: Invalid date type '${typeof param}'.`);
204 : 1 : }
205 : 20 : }
206 : 83 :
207 : 83 : /**
208 : 83 : * @method validateParamUnitGroup
209 : 83 : * @static
210 : 83 : * @memberof module:weather.Weather
211 : 83 : * @param {string} param - The system of units used for the output data.
212 : 83 : * @returns {string} The validated unitGroup to specify the units that will be used when returning weather data.
213 : 83 : * @desc Validate and return the system of units used for the output data.
214 : 83 : * @throws {TypeError|Error} If the input data type is not a string, or an unsupported value is used.
215 : 83 : */
216 [ + ]: 83 : static validateParamUnitGroup(param){
217 [ + ]: 6 : if(typeof param === 'string'){
218 [ + ]: 5 : if(['us', 'uk', 'metric', 'base'].includes(param)){
219 : 4 : return param;
220 [ + ]: 4 : }
221 : 1 : else{
222 : 1 : throw new Error(`Weather.validateParamUnitGroup: Invalid unitGroup value '${param}'.`);
223 : 1 : }
224 [ + ]: 5 : }
225 : 1 : else{
226 : 1 : throw new TypeError(`Weather.validateParamUnitGroup: Invalid unitGroup type '${typeof param}'.`);
227 : 1 : }
228 : 6 : }
229 : 83 :
230 : 83 : /**
231 : 83 : * @method validateParamInclude
232 : 83 : * @static
233 : 83 : * @memberof module:weather.Weather
234 : 83 : * @param {Array<string>} param - The sections to include in the result data.
235 : 83 : * @returns {string} The validated sections to include in the result data as a comma separated list.
236 : 83 : * @desc Specifies the sections to include in the result data.
237 : 83 : * @throws {TypeError|Error} If the input data type is not a string, or an unsupported value is used.
238 : 83 : */
239 [ + ]: 83 : static validateParamInclude(...param){
240 [ + ]: 3 : for(let p of param){
241 [ + ]: 7 : if(typeof p === 'string'){
242 : 6 : if(![
243 : 6 : 'days', // daily data
244 : 6 : 'hours', // hourly data
245 : 6 : 'minutes', // minutely data (beta). See Requesting sub-hourly data in the Timeline Weather API.
246 : 6 : 'alerts', // weather alerts
247 : 6 : 'current', // current conditions or conditions at requested time.
248 : 6 : 'events', // historical events such as a hail, tornadoes, wind damage and earthquakes (not enabled by default).
249 : 6 : 'obs', // historical observations from weather stations.
250 : 6 : 'remote', // historical observations from remote source such as satellite or radar.
251 : 6 : 'fcst', // forecast based on 16 day models.
252 : 6 : 'stats', // historical statistical normals and daily statistical forecast.
253 : 6 : 'statsfcst', // use the full statistical forecast information for dates in the future beyond the current model forecast.
254 [ + ]: 6 : ].includes(p)){
255 : 1 : throw new Error(`Weather.validateParamInclude: Invalid include parameter '${p}'.`);
256 : 1 : }
257 [ + ]: 6 : }
258 : 1 : else{
259 : 1 : throw new TypeError(`Weather.validateParamInclude: Invalid include parameter type '${typeof p}'.`);
260 : 1 : }
261 [ + ]: 7 : }
262 : 1 : return param.join(',');
263 : 3 : }
264 : 83 :
265 : 83 : /**
266 : 83 : * @method validateParamElements
267 : 83 : * @static
268 : 83 : * @memberof module:weather.Weather
269 : 83 : * @param {Array<string>} param - The specific weather elements to include in the result data.
270 : 83 : * @returns {string} The validated weather elements to include in the result data as a comma separated list.
271 : 83 : * @desc Specifies the specific weather elements to include in the result data.
272 : 83 : * @throws {TypeError|Error} If the input data type is not a string, or an unsupported value is used.
273 : 83 : */
274 [ + ]: 83 : static validateParamElements(...param){
275 [ + ]: 3 : for(let p of param){
276 [ + ]: 7 : if(typeof p === 'string'){
277 : 6 : if(![
278 : 6 : 'tempmax',
279 : 6 : 'tempmin',
280 : 6 : 'temp',
281 : 6 : 'feelslikemax',
282 : 6 : 'feelslikemin',
283 : 6 : 'feelslike',
284 : 6 : 'dew',
285 : 6 : 'humidity',
286 : 6 : 'precip',
287 : 6 : 'precipprob',
288 : 6 : 'precipcover',
289 : 6 : 'preciptype',
290 : 6 : 'snow',
291 : 6 : 'snowdepth',
292 : 6 : 'windgust',
293 : 6 : 'windspeed',
294 : 6 : 'winddir',
295 : 6 : 'pressure',
296 : 6 : 'cloudcover',
297 : 6 : 'visibility',
298 : 6 : 'solarradiation',
299 : 6 : 'solarenergy',
300 : 6 : 'uvindex',
301 : 6 : 'sunrise',
302 : 6 : 'sunriseEpoch',
303 : 6 : 'sunset',
304 : 6 : 'sunsetEpoch',
305 : 6 : 'moonphase',
306 : 6 : 'conditions',
307 : 6 : 'description',
308 : 6 : 'icon',
309 : 6 : 'icon',
310 : 6 : 'stations',
311 : 6 : 'source',
312 [ + ]: 6 : ].includes(p)){
313 : 1 : throw new Error(`Weather.validateParamElements: Invalid elements parameter '${p}'.`);
314 : 1 : }
315 [ + ]: 6 : }
316 : 1 : else{
317 : 1 : throw new TypeError(`Weather.validateParamElements: Invalid elements parameter type '${typeof p}'.`);
318 : 1 : }
319 [ + ]: 7 : }
320 : 1 : return param.join(',');
321 : 3 : }
322 : 83 :
323 : 83 : /**
324 : 83 : * @method fetchWeatherData
325 : 83 : * @instance
326 : 83 : * @async
327 : 83 : * @memberof module:weather.Weather
328 : 83 : * @param {string} location - Location for which weather data is requested.
329 : 83 : * @param {string} fromDate - Start date of the weather data period (in `yyyy-MM-dd` format).
330 : 83 : * @param {string} toDate - End date of the weather data period (in `yyyy-MM-dd` format).
331 : 83 : * @param {string} unitGroup - Unit system for the weather data ('us', 'metric', 'uk' or 'base').
332 : 83 : * @param {string} include - Data types to include (e.g., 'days', 'hours').
333 : 83 : * @param {string} elements - Specific weather elements to retrieve.
334 : 83 : * @returns {Promise<object>} The weather data as a dictionary.
335 : 83 : * @desc Fetch weather data for a specified location and date range.
336 : 83 : */
337 [ + ]: 83 : async fetchWeatherData(location, fromDate = '', toDate = '', unitGroup = 'metric', include = '', elements = ''){
338 : 7 : try{
339 [ + ]: 7 : if(!this.apiKey){
340 : 1 : throw new Error('Weather.fetchWeatherData: No API key or session found.');
341 [ + ]: 1 : }
342 : 6 :
343 [ + ]: 7 : if(!location){
344 : 1 : throw new Error('Weather.fetchWeatherData: Bad API Request:A location must be specified.');
345 [ + ]: 1 : }
346 : 5 :
347 : 5 : let queryParams = new URLSearchParams({
348 : 5 : key : this.apiKey,
349 : 5 : lang: 'en',
350 : 5 : contentType: 'json',
351 : 5 : unitGroup,
352 : 5 : include,
353 : 5 : elements,
354 : 5 : });
355 : 5 :
356 : 5 : let url;
357 : 5 : if(fromDate)
358 [ + ][ + ]: 7 : url = `${BASE_URL}/${location}/${fromDate}/${toDate}?${queryParams}`;
359 : 1 : else
360 [ + ]: 1 : url = `${BASE_URL}/${location}/?${queryParams}`;
361 : 5 :
362 [ + ]: 7 : if(globalThis.fetch){
363 : 2 : const response = await fetch(url);
364 : 2 :
365 [ + ]: 2 : if(!response.ok){
366 : 1 : throw new Error(await response.text());
367 : 1 : }
368 : 1 : this.#weatherData = await response.json();
369 : 1 :
370 : 1 : return this.#weatherData;
371 [ + ]: 1 : }
372 : 3 : else{
373 [ + ]: 3 : return new Promise((resolve, reject) => {
374 : 3 :
375 [ + ]: 3 : let cr = https.request(url, (response) => {
376 : 3 :
377 : 3 : response.setEncoding('utf8');
378 : 3 : let body = '';
379 : 3 :
380 [ + ]: 3 : response.on('data', (chunk) => { body += chunk });
381 [ + ]: 3 : response.on('end', () => {
382 [ + ]: 3 : if(response.statusCode >= 200 && response.statusCode < 300){
383 : 2 : resolve(JSON.parse(body));
384 [ + ]: 2 : }
385 : 1 : else{
386 : 1 : reject(body);
387 : 1 : }
388 : 3 : });
389 : 3 : });
390 : 3 : cr.end();
391 : 3 : });
392 : 3 : }
393 : 7 : }
394 [ + ]: 7 : catch(error){
395 : 3 : throw error;
396 : 3 : }
397 : 7 : }
398 : 83 :
399 : 83 : /**
400 : 83 : * Data Elements
401 : 83 : *
402 : 83 : * @method clearWeatherData
403 : 83 : * @instance
404 : 83 : * @memberof module:weather.Weather
405 : 83 : * @desc Clear the weather data of the class.
406 : 83 : */
407 [ + ]: 83 : clearWeatherData(){
408 : 1 : this.#weatherData = {};
409 : 1 : }
410 : 83 :
411 : 83 : /**
412 : 83 : * Data Elements
413 : 83 : *
414 : 83 : * @method getWeatherData
415 : 83 : * @instance
416 : 83 : * @memberof module:weather.Weather
417 : 83 : * @param {Array<string>} elements - List of elements to include in the returned data.
418 : 83 : * @returns {object|null} The weather data as a dictionary, filtered by elements if specified, or null for errors.
419 : 83 : * @desc Get the stored weather data.
420 : 83 : */
421 [ + ]: 83 : getWeatherData(elements = []){
422 : 4 : try{
423 [ + ]: 4 : if(elements.length > 0){
424 : 2 : return extractSubobjectByKeys(this.#weatherData, elements);
425 : 2 : }
426 : 2 : else{
427 : 2 : return this.#weatherData;
428 : 2 : }
429 : 4 : }
430 [ + ]: 4 : catch(error){
431 : 1 : return null;
432 : 1 : }
433 : 4 : }
434 : 83 :
435 : 83 : /**
436 : 83 : * Data Elements
437 : 83 : *
438 : 83 : * @method setWeatherData
439 : 83 : * @instance
440 : 83 : * @memberof module:weather.Weather
441 : 83 : * @param {object} data - Weather data to store.
442 : 83 : * @desc Set the internal weather data.
443 : 83 : */
444 [ + ]: 83 : setWeatherData(data){
445 : 75 : this.#weatherData = data;
446 : 75 : }
447 : 83 :
448 : 83 : /**
449 : 83 : * Data Elements
450 : 83 : *
451 : 83 : * @method getWeatherDailyData
452 : 83 : * @instance
453 : 83 : * @memberof module:weather.Weather
454 : 83 : * @param {Array<string>} elements - List of elements to include in the returned data.
455 : 83 : * @returns {Array<object>|null} List of daily data dictionaries, filtered by elements if specified, or null for errors.
456 : 83 : * @desc Get daily weather data, optionally filtered by elements.
457 : 83 : */
458 [ + ]: 83 : getWeatherDailyData(elements = []){
459 : 4 : try{
460 [ + ]: 4 : if(elements.length > 0){
461 [ + ]: 2 : return this.#weatherData.days.map(day => extractSubobjectByKeys(day, elements));
462 : 2 : }
463 : 2 : else{
464 : 2 : return this.#weatherData.days;
465 : 2 : }
466 : 4 : }
467 [ + ]: 4 : catch(error){
468 : 1 : return null;
469 : 1 : }
470 : 4 : }
471 : 83 :
472 : 83 : /**
473 : 83 : * Data Elements
474 : 83 : *
475 : 83 : * @method setWeatherDailyData
476 : 83 : * @instance
477 : 83 : * @memberof module:weather.Weather
478 : 83 : * @param {Array<object>} dailyData - List of daily weather data dictionaries.
479 : 83 : * @desc Set the daily weather data.
480 : 83 : */
481 [ + ]: 83 : setWeatherDailyData(dailyData){
482 : 1 : this.#weatherData.days = dailyData;
483 : 1 : }
484 : 83 :
485 : 83 : /**
486 : 83 : * Data Elements
487 : 83 : *
488 : 83 : * @method getWeatherHourlyData
489 : 83 : * @instance
490 : 83 : * @memberof module:weather.Weather
491 : 83 : * @param {Array<string>} elements - List of elements to include in the returned data.
492 : 83 : * @returns {Array<object>|null} List of hourly data dictionaries, filtered by elements if specified, or null for errors.
493 : 83 : * @desc Get hourly weather data for all days, optionally filtered by elements.
494 : 83 : */
495 [ + ]: 83 : getWeatherHourlyData(elements = []){
496 : 3 : try{
497 [ + ]: 3 : const hourlyData = this.#weatherData.days.flatMap(day => day.hours);
498 [ + ]: 3 : if(elements.length > 0){
499 [ + ]: 2 : return hourlyData.map(hourDt => extractSubobjectByKeys(hourDt, elements));
500 [ + ]: 2 : }
501 : 1 : else{
502 : 1 : return hourlyData;
503 : 1 : }
504 : 3 : }
505 [ + ]: 3 : catch(error){
506 : 1 : return null;
507 : 1 : }
508 : 3 : }
509 : 83 :
510 : 83 : /**
511 : 83 : * Data Elements
512 : 83 : *
513 : 83 : * @method getDataOnDay
514 : 83 : * @instance
515 : 83 : * @memberof module:weather.Weather
516 : 83 : * @param {string|number} dayInfo - The identifier for the day, which can be a date string (YYYY-MM-DD) or an index of the day list.
517 : 83 : * @param {Array<string>} elements - Specific weather elements to retrieve.
518 : 83 : * @returns {object|null} The weather data dictionary for the specified day, or null for errors.
519 : 83 : * @desc Retrieves weather data for a specific day based on a date string or index.
520 : 83 : */
521 [ + ]: 83 : getDataOnDay(dayInfo, elements = []){
522 : 7 : try{
523 : 7 : let dayData;
524 : 7 :
525 [ + ]: 7 : if(typeof dayInfo === 'string'){
526 [ + ]: 3 : dayData = this.#weatherData.days.find(day => day.datetime === dayInfo);
527 [ + ]: 3 : }
528 : 4 : else
529 [ + ]: 4 : if(typeof dayInfo === 'number'){
530 : 3 : dayData = this.#weatherData.days[dayInfo];
531 [ + ]: 3 : }
532 : 1 : else{
533 : 1 : throw new TypeError(`Weather.getDataOnDay: Invalid input day value '${dayInfo}'.`);
534 [ + ]: 1 : }
535 : 6 :
536 [ + ]: 7 : if(elements.length > 0){
537 : 1 : return extractSubobjectByKeys(dayData, elements);
538 [ + ]: 1 : }
539 : 5 : else{
540 : 5 : return dayData;
541 : 5 : }
542 : 7 : }
543 [ + ]: 7 : catch(error){
544 : 1 : return null;
545 : 1 : }
546 : 7 : }
547 : 83 :
548 : 83 : /**
549 : 83 : * Data Elements
550 : 83 : *
551 : 83 : * @method setDataOnDay
552 : 83 : * @instance
553 : 83 : * @memberof module:weather.Weather
554 : 83 : * @param {string|number} dayInfo - The identifier for the day, which can be a date string (YYYY-MM-DD) or an index of the day list.
555 : 83 : * @param {object} data - The new weather data dictionary to replace the existing day's data.
556 : 83 : * @desc Updates weather data for a specific day based on a date string or index.
557 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
558 : 83 : */
559 [ + ]: 83 : setDataOnDay(dayInfo, data){
560 : 3 : try{
561 [ + ]: 3 : if(typeof dayInfo === 'string'){
562 : 1 : for(let i = 0; i < this.#weatherData.days.length; i++){
563 : 1 : if(this.#weatherData.days[i].datetime === dayInfo){
564 : 1 : this.#weatherData.days[i] = data;
565 : 1 : break;
566 : 1 : }
567 : 1 : }
568 [ + ]: 1 : }
569 : 2 : else
570 [ + ]: 2 : if(typeof dayInfo === 'number'){
571 : 1 : this.#weatherData.days[dayInfo] = data;
572 : 1 : }
573 : 1 : else{
574 : 1 : throw new TypeError(`Weather.setDataOnDay: Invalid input day value '${dayInfo}'.`);
575 : 1 : }
576 : 3 : }
577 [ + ]: 3 : catch(error){
578 : 1 : throw error;
579 : 1 : }
580 : 3 : }
581 : 83 :
582 : 83 : /**
583 : 83 : * Data Elements
584 : 83 : *
585 : 83 : * @method getHourlyDataOnDay
586 : 83 : * @instance
587 : 83 : * @memberof module:weather.Weather
588 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
589 : 83 : * @param {Array} elements - Optional list of keys to filter the hourly data.
590 : 83 : * @returns {Array} A list of hourly data dictionaries for the specified day.
591 : 83 : * @desc Retrieves hourly weather data for a specific day identified by date or index. Optionally filters the data to include only specified elements.
592 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
593 : 83 : */
594 [ + ]: 83 : getHourlyDataOnDay(dayInfo, elements = []){
595 : 8 : try{
596 : 8 : let hourlyData;
597 [ + ]: 8 : if(typeof dayInfo === 'string'){
598 [ + ][ + ][ + ]: 4 : hourlyData = this.#weatherData.days.find(day => day.datetime === dayInfo)?.hours || [];
599 [ + ]: 4 : }
600 : 4 : else
601 [ + ]: 4 : if(typeof dayInfo === 'number'){
602 [ + ][ + ]: 3 : hourlyData = this.#weatherData.days[dayInfo]?.hours || [];
603 [ + ]: 3 : }
604 : 1 : else {
605 : 1 : throw new TypeError(`Weather.getHourlyDataOnDay: Invalid input day value '${dayInfo}'.`);
606 [ + ]: 1 : }
607 : 7 :
608 [ + ]: 8 : if(elements.length > 0){
609 [ + ]: 1 : return hourlyData.map(hour => {
610 : 24 : const filtered = {};
611 [ + ]: 24 : elements.forEach(el => {
612 : 24 : filtered[el] = hour[el];
613 : 24 : });
614 : 24 : return filtered;
615 : 1 : });
616 [ + ]: 1 : }
617 : 6 : return hourlyData;
618 : 6 : }
619 [ + ]: 8 : catch(error){
620 : 1 : throw error;
621 : 1 : }
622 : 8 : }
623 : 83 :
624 : 83 : /**
625 : 83 : * Data Elements
626 : 83 : *
627 : 83 : * @method setHourlyDataOnDay
628 : 83 : * @instance
629 : 83 : * @memberof module:weather.Weather
630 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
631 : 83 : * @param {Array} data - The new list of hourly weather data dictionaries to set.
632 : 83 : * @desc Sets the hourly weather data for a specific day identified by date or index.
633 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
634 : 83 : */
635 [ + ]: 83 : setHourlyDataOnDay(dayInfo, data){
636 : 3 : try{
637 [ + ]: 3 : if(typeof dayInfo === 'string'){
638 : 1 : for(let day of this.#weatherData.days){
639 : 1 : if(day.datetime === dayInfo){
640 : 1 : day.hours = data;
641 : 1 : break;
642 : 1 : }
643 : 1 : }
644 [ + ]: 1 : }
645 : 2 : else
646 [ + ]: 2 : if(typeof dayInfo === 'number'){
647 : 1 : this.#weatherData.days[dayInfo].hours = data;
648 : 1 : }
649 : 1 : else{
650 : 1 : throw new TypeError(`Weather.setHourlyDataOnDay: Invalid input day value '${dayInfo}'.`);
651 : 1 : }
652 : 3 : }
653 [ + ]: 3 : catch(error){
654 : 1 : throw error;
655 : 1 : }
656 : 3 : }
657 : 83 :
658 : 83 : /**
659 : 83 : * Data Elements
660 : 83 : *
661 : 83 : * @method getDataAtDatetime
662 : 83 : * @instance
663 : 83 : * @memberof module:weather.Weather
664 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index, pointing to a specific day in the data.
665 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index, pointing to a specific time slot in the day's data.
666 : 83 : * @param {Array} elements - Specific weather elements to retrieve.
667 : 83 : * @returns {Object} The specific hourly data dictionary corresponding to the given day and time.
668 : 83 : * @desc Retrieves weather data for a specific date and time from the weather data collection.
669 : 83 : * @throws {Error} Propagates any exceptions that may occur during data retrieval.
670 : 83 : */
671 [ + ]: 83 : getDataAtDatetime(dayInfo, timeInfo, elements = []){
672 : 4 : try{
673 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
674 : 4 : const data = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
675 : 4 :
676 [ + ]: 4 : if(elements.length){
677 : 1 : return extractSubobjectByKeys(data, elements);
678 [ + ]: 1 : }
679 : 2 : else{
680 : 2 : return data;
681 : 2 : }
682 : 4 : }
683 [ + ]: 4 : catch(error){
684 : 1 : throw error;
685 : 1 : }
686 : 4 : }
687 : 83 :
688 : 83 : /**
689 : 83 : * Data Elements
690 : 83 : *
691 : 83 : * @method setDataAtDatetime
692 : 83 : * @instance
693 : 83 : * @memberof module:weather.Weather
694 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index, pointing to a specific day in the data.
695 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index, pointing to a specific time slot in the day's data.
696 : 83 : * @param {Object} data - The data dictionary to be set for the specific hourly time slot.
697 : 83 : * @desc Sets weather data for a specific date and time from the weather data collection.
698 : 83 : * @throws {Error} Propagates any exceptions that may occur during data setting.
699 : 83 : */
700 [ + ]: 83 : setDataAtDatetime(dayInfo, timeInfo, data){
701 : 2 : try{
702 : 2 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
703 : 2 : Weather.setItemByDatetimeVal(dayItem.hours, timeInfo, data);
704 : 2 : }
705 [ + ]: 2 : catch(error){
706 : 1 : throw error;
707 : 1 : }
708 : 2 : }
709 : 83 :
710 : 83 : /**
711 : 83 : * Data Elements
712 : 83 : *
713 : 83 : * @method updateDataAtDatetime
714 : 83 : * @instance
715 : 83 : * @memberof module:weather.Weather
716 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index, pointing to a specific day in the data.
717 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index, pointing to a specific time slot in the day's data.
718 : 83 : * @param {Object} data - The data dictionary to be updated for the specific hourly time slot.
719 : 83 : * @desc Updates weather data for a specific date and time in the weather data collection.
720 : 83 : * @throws {Error} Propagates any exceptions that may occur during data setting.
721 : 83 : */
722 [ + ]: 83 : updateDataAtDatetime(dayInfo, timeInfo, data){
723 : 2 : try{
724 : 2 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
725 : 2 : Weather.updateItemByDatetimeVal(dayItem.hours, timeInfo, data);
726 : 2 : }
727 [ + ]: 2 : catch(error){
728 : 1 : throw error;
729 : 1 : }
730 : 2 : }
731 : 83 :
732 : 83 : /**
733 : 83 : * Data Elements
734 : 83 : *
735 : 83 : * @method getDatetimeEpochAtDatetime
736 : 83 : * @instance
737 : 83 : * @memberof module:weather.Weather
738 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
739 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
740 : 83 : * @returns {number} The epoch time corresponding to the specific day and time.
741 : 83 : * @desc Retrieves the epoch time for a specific datetime within the weather data.
742 : 83 : * @throws {Error} Propagates any exceptions that may occur during data retrieval.
743 : 83 : */
744 [ + ]: 83 : getDatetimeEpochAtDatetime(dayInfo, timeInfo){
745 : 3 : try{
746 : 3 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
747 : 3 : return Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).datetimeEpoch;
748 : 3 : }
749 [ + ]: 3 : catch(error){
750 : 2 : throw error;
751 : 2 : }
752 : 3 : }
753 : 83 :
754 : 83 : /**
755 : 83 : * Data Elements
756 : 83 : *
757 : 83 : * @method setDatetimeEpochAtDatetime
758 : 83 : * @instance
759 : 83 : * @memberof module:weather.Weather
760 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
761 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
762 : 83 : * @param {number} value - The epoch time value to be set.
763 : 83 : * @desc Sets the epoch time for a specific datetime within the weather data.
764 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
765 : 83 : */
766 [ + ]: 83 : setDatetimeEpochAtDatetime(dayInfo, timeInfo, value){
767 : 3 : try{
768 : 3 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
769 : 3 : Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).datetimeEpoch = value;
770 : 3 : }
771 [ + ]: 3 : catch(error){
772 : 2 : throw error;
773 : 2 : }
774 : 3 : }
775 : 83 :
776 : 83 : /**
777 : 83 : * Data Elements
778 : 83 : *
779 : 83 : * @method getDailyDatetimes(
780 : 83 : * @instance
781 : 83 : * @memberof module:weather.Weather
782 : 83 : * @returns {Array<Date>} A list of Date objects parsed from the 'datetime' key of each day in the weather data.
783 : 83 : * @desc Retrieves a list of datetime objects representing each day's date from the weather data.
784 : 83 : */
785 [ + ]: 83 : getDailyDatetimes(){
786 [ + ]: 1 : return this.#weatherData.days.map(day => new Date(day.datetime));
787 : 1 : }
788 : 83 :
789 : 83 : /**
790 : 83 : * Data Elements
791 : 83 : *
792 : 83 : * @method getHourlyDatetimes
793 : 83 : * @instance
794 : 83 : * @memberof module:weather.Weather
795 : 83 : * @returns {Array<Date>} A list of Date objects parsed from the 'datetime' keys of each day and hour in the weather data.
796 : 83 : * @desc Retrieves a list of datetime objects representing each hour's datetime from the weather data.
797 : 83 : */
798 [ + ]: 83 : getHourlyDatetimes(){
799 [ + ]: 1 : return this.#weatherData.days.flatMap(day =>
800 [ + ]: 1 : day.hours.map(hour => new Date(`${day.datetime}T${hour.datetime}`))
801 : 1 : );
802 : 1 : }
803 : 83 :
804 : 83 : /**
805 : 83 : * Location Elements
806 : 83 : *
807 : 83 : * @method getLatitude
808 : 83 : * @instance
809 : 83 : * @memberof module:weather.Weather
810 : 83 : * @returns {number|null} The latitude if available, otherwise null.
811 : 83 : * @desc Retrieves the latitude from the weather data.
812 : 83 : */
813 [ + ]: 83 : getLatitude(){
814 [ - ]: 1 : return this.#weatherData.latitude === 0 ? 0 : (this.#weatherData.latitude || null);
815 : 1 : }
816 : 83 :
817 : 83 : /**
818 : 83 : * Location Elements
819 : 83 : *
820 : 83 : * @method setLatitude
821 : 83 : * @instance
822 : 83 : * @memberof module:weather.Weather
823 : 83 : * @param {number} value - The new latitude to be set.
824 : 83 : * @desc Sets the latitude in the weather data.
825 : 83 : * @throws {RangeError} If the latitude value is out of <-90, 90> range.
826 : 83 : */
827 [ + ]: 83 : setLatitude(value){
828 [ + ]: 2 : if(value < -90 || value > 90)
829 [ + ]: 2 : throw new RangeError(`Weather.setLatitude: invalid latitude value '${value}'.`);
830 : 1 :
831 : 1 : this.#weatherData.latitude = value;
832 : 2 : }
833 : 83 :
834 : 83 : /**
835 : 83 : * Location Elements
836 : 83 : *
837 : 83 : * @method getLongitude
838 : 83 : * @instance
839 : 83 : * @memberof module:weather.Weather
840 : 83 : * @returns {number|null} The longitude if available, otherwise null.
841 : 83 : * @desc Retrieves the longitude from the weather data.
842 : 83 : */
843 [ + ]: 83 : getLongitude(){
844 [ - ]: 1 : return this.#weatherData.longitude === 0 ? 0 : (this.#weatherData.longitude || null);
845 : 1 : }
846 : 83 :
847 : 83 : /**
848 : 83 : * Location Elements
849 : 83 : *
850 : 83 : * @method setLongitude
851 : 83 : * @instance
852 : 83 : * @memberof module:weather.Weather
853 : 83 : * @param {number} value - The new longitude to be set.
854 : 83 : * @desc Sets the longitude in the weather data.
855 : 83 : * @throws {RangeError} If the longitude value is out of <-180, 180> range.
856 : 83 : */
857 [ + ]: 83 : setLongitude(value){
858 [ + ]: 2 : if(value < -180 || value > 180)
859 [ + ]: 2 : throw new RangeError(`Weather.setLongitude: invalid longitude value '${value}'.`);
860 : 1 :
861 : 1 : this.#weatherData.longitude = value;
862 : 2 : }
863 : 83 :
864 : 83 : /**
865 : 83 : * Location Elements
866 : 83 : *
867 : 83 : * @method getResolvedAddress
868 : 83 : * @instance
869 : 83 : * @memberof module:weather.Weather
870 : 83 : * @returns {string|null} The resolved address if available, otherwise null.
871 : 83 : * @desc Retrieves the resolved address from the weather data.
872 : 83 : */
873 [ + ]: 83 : getResolvedAddress(){
874 [ - ]: 1 : return this.#weatherData.resolvedAddress || null;
875 : 1 : }
876 : 83 :
877 : 83 : /**
878 : 83 : * Location Elements
879 : 83 : *
880 : 83 : * @method setResolvedAddress
881 : 83 : * @instance
882 : 83 : * @memberof module:weather.Weather
883 : 83 : * @param {string} value - The new resolved address to be set.
884 : 83 : * @desc Sets the resolved address in the weather data.
885 : 83 : */
886 [ + ]: 83 : setResolvedAddress(value){
887 : 1 : this.#weatherData.resolvedAddress = value;
888 : 1 : }
889 : 83 :
890 : 83 : /**
891 : 83 : * Location Elements
892 : 83 : *
893 : 83 : * @method getAddress
894 : 83 : * @instance
895 : 83 : * @memberof module:weather.Weather
896 : 83 : * @returns {string|null} The address if available, otherwise null.
897 : 83 : * @desc Retrieves the address from the weather data.
898 : 83 : */
899 [ + ]: 83 : getAddress(){
900 [ - ]: 1 : return this.#weatherData.address || null;
901 : 1 : }
902 : 83 :
903 : 83 : /**
904 : 83 : * Location Elements
905 : 83 : *
906 : 83 : * @method setAddress
907 : 83 : * @instance
908 : 83 : * @memberof module:weather.Weather
909 : 83 : * @param {string} value - The new address to be set.
910 : 83 : * @desc Sets the address in the weather data.
911 : 83 : */
912 [ + ]: 83 : setAddress(value){
913 : 1 : this.#weatherData.address = value;
914 : 1 : }
915 : 83 :
916 : 83 : /**
917 : 83 : * Location Elements
918 : 83 : *
919 : 83 : * @method getTimezone
920 : 83 : * @instance
921 : 83 : * @memberof module:weather.Weather
922 : 83 : * @returns {string|null} The timezone if available, otherwise null.
923 : 83 : * @desc Retrieves the timezone from the weather data.
924 : 83 : */
925 [ + ]: 83 : getTimezone(){
926 [ - ]: 1 : return this.#weatherData.timezone || null;
927 : 1 : }
928 : 83 :
929 : 83 : /**
930 : 83 : * Location Elements
931 : 83 : *
932 : 83 : * @method setTimezone
933 : 83 : * @instance
934 : 83 : * @memberof module:weather.Weather
935 : 83 : * @param {string} value - The new timezone to be set.
936 : 83 : * @desc Sets the timezone in the weather data.
937 : 83 : */
938 [ + ]: 83 : setTimezone(value){
939 : 1 : this.#weatherData.timezone = value;
940 : 1 : }
941 : 83 :
942 : 83 : /**
943 : 83 : * Location Elements
944 : 83 : *
945 : 83 : * @method getTzoffset
946 : 83 : * @instance
947 : 83 : * @memberof module:weather.Weather
948 : 83 : * @returns {number|null} The timezone offset if available, otherwise null.
949 : 83 : * @desc Retrieves the timezone offset from the weather data.
950 : 83 : */
951 [ + ]: 83 : getTzoffset(){
952 [ - ]: 1 : return this.#weatherData.tzoffset === 0 ? 0 : (this.#weatherData.tzoffset || null);
953 : 1 : }
954 : 83 :
955 : 83 : /**
956 : 83 : * Location Elements
957 : 83 : *
958 : 83 : * @method setTzoffset
959 : 83 : * @instance
960 : 83 : * @memberof module:weather.Weather
961 : 83 : * @param {number} value - The new timezone offset to be set.
962 : 83 : * @desc Sets the timezone offset in the weather data.
963 : 83 : */
964 [ + ]: 83 : setTzoffset(value){
965 : 1 : this.#weatherData.tzoffset = value;
966 : 1 : }
967 : 83 :
968 : 83 : /**
969 : 83 : * Request Elements
970 : 83 : *
971 : 83 : * @method getQueryCost
972 : 83 : * @instance
973 : 83 : * @memberof module:weather.Weather
974 : 83 : * @returns {number|null} The cost of the query if available, otherwise null.
975 : 83 : * @desc Retrieves the cost of the query from the weather data.
976 : 83 : */
977 [ + ]: 83 : getQueryCost(){
978 [ + ]: 2 : return this.#weatherData.queryCost || null;
979 : 2 : }
980 : 83 :
981 : 83 : /**
982 : 83 : * Request Elements
983 : 83 : *
984 : 83 : * @method setQueryCost
985 : 83 : * @instance
986 : 83 : * @memberof module:weather.Weather
987 : 83 : * @param {number} value - The new cost to be set for the query.
988 : 83 : * @desc Sets the cost of the query in the weather data.
989 : 83 : */
990 [ + ]: 83 : setQueryCost(value){
991 : 2 : this.#weatherData.queryCost = value;
992 : 2 : }
993 : 83 :
994 : 83 : /**
995 : 83 : * Request Elements
996 : 83 : *
997 : 83 : * @method getStations
998 : 83 : * @instance
999 : 83 : * @memberof module:weather.Weather
1000 : 83 : * @returns {Array} The list of weather stations if available, otherwise an empty list.
1001 : 83 : * @desc Retrieves the list of weather stations from the weather data.
1002 : 83 : */
1003 [ + ]: 83 : getStations(){
1004 [ + ]: 2 : return this.#weatherData.stations || [];
1005 : 2 : }
1006 : 83 :
1007 : 83 : /**
1008 : 83 : * Request Elements
1009 : 83 : *
1010 : 83 : * @method setStations
1011 : 83 : * @instance
1012 : 83 : * @memberof module:weather.Weather
1013 : 83 : * @param {Array} value - The new list of weather stations to be set.
1014 : 83 : * @desc Sets the list of weather stations in the weather data.
1015 : 83 : */
1016 [ + ]: 83 : setStations(value){
1017 : 2 : this.#weatherData.stations = value;
1018 : 2 : }
1019 : 83 :
1020 : 83 : /**
1021 : 83 : * Core Weather Elements
1022 : 83 : *
1023 : 83 : * @method getTempOnDay
1024 : 83 : * @instance
1025 : 83 : * @memberof module:weather.Weather
1026 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1027 : 83 : * @returns {number|null} The temperature for the specified day, or null if not available or error.
1028 : 83 : * @desc Retrieves the temperature for a specific day identified by date or index.
1029 : 83 : */
1030 [ + ]: 83 : getTempOnDay(dayInfo){
1031 : 4 : try{
1032 [ + ]: 4 : if(typeof dayInfo === 'string'){
1033 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.temp;
1034 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1035 [ + ]: 2 : }
1036 : 2 : else
1037 [ + ]: 2 : if(typeof dayInfo === 'number'){
1038 : 1 : let tmp = this.#weatherData.days[dayInfo]?.temp;
1039 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1040 [ + ]: 1 : }
1041 : 1 : else{
1042 : 1 : throw new TypeError(`Weather.getTempOnDay: Invalid input day value '${dayInfo}'.`);
1043 : 1 : }
1044 : 4 : }
1045 [ + ]: 4 : catch(error){
1046 : 1 : return null;
1047 : 1 : }
1048 : 4 : }
1049 : 83 :
1050 : 83 : /**
1051 : 83 : * Core Weather Elements
1052 : 83 : *
1053 : 83 : * @method setTempOnDay
1054 : 83 : * @instance
1055 : 83 : * @memberof module:weather.Weather
1056 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1057 : 83 : * @param {number} value - The new temperature value to set.
1058 : 83 : * @desc Sets the temperature for a specific day identified by date or index.
1059 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1060 : 83 : */
1061 [ + ]: 83 : setTempOnDay(dayInfo, value){
1062 : 3 : try{
1063 [ + ]: 3 : if(typeof dayInfo === 'string'){
1064 [ + ]: 1 : let day = this.#weatherData.days.find(day => day.datetime === dayInfo);
1065 : 1 : if(day) day.temp = value;
1066 [ + ]: 1 : }
1067 : 2 : else
1068 [ + ]: 2 : if(typeof dayInfo === 'number'){
1069 : 1 : let day = this.#weatherData.days[dayInfo];
1070 : 1 : if(day) day.temp = value;
1071 : 1 : }
1072 : 1 : else {
1073 : 1 : throw new TypeError(`Weather.setTempOnDay: Invalid input day value '${dayInfo}'.`);
1074 : 1 : }
1075 : 3 : }
1076 [ + ]: 3 : catch(error){
1077 : 1 : throw error;
1078 : 1 : }
1079 : 3 : }
1080 : 83 :
1081 : 83 : /**
1082 : 83 : * Core Weather Elements
1083 : 83 : *
1084 : 83 : * @method getTempmaxOnDay
1085 : 83 : * @instance
1086 : 83 : * @memberof module:weather.Weather
1087 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1088 : 83 : * @returns {number|null} The maximum temperature for the specified day, or null if not available or error.
1089 : 83 : * @desc Retrieves the maximum temperature for a specific day identified by date or index.
1090 : 83 : */
1091 [ + ]: 83 : getTempmaxOnDay(dayInfo){
1092 : 4 : try{
1093 [ + ]: 4 : if(typeof dayInfo === 'string'){
1094 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.tempmax;
1095 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1096 [ + ]: 2 : }
1097 : 2 : else
1098 [ + ]: 2 : if(typeof dayInfo === 'number'){
1099 : 1 : let tmp = this.#weatherData.days[dayInfo]?.tempmax;
1100 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1101 [ + ]: 1 : }
1102 : 1 : else{
1103 : 1 : throw new TypeError(`Weather.getTempmaxOnDay: Invalid input day value '${dayInfo}'.`);
1104 : 1 : }
1105 : 4 : }
1106 [ + ]: 4 : catch(error){
1107 : 1 : return null;
1108 : 1 : }
1109 : 4 : }
1110 : 83 :
1111 : 83 : /**
1112 : 83 : * Core Weather Elements
1113 : 83 : *
1114 : 83 : * @method setTempmaxOnDay
1115 : 83 : * @instance
1116 : 83 : * @memberof module:weather.Weather
1117 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1118 : 83 : * @param {number} value - The new maximum temperature value to set.
1119 : 83 : * @desc Sets the maximum temperature for a specific day identified by date or index.
1120 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1121 : 83 : */
1122 [ + ]: 83 : setTempmaxOnDay(dayInfo, value){
1123 : 3 : try{
1124 [ + ]: 3 : if(typeof dayInfo === 'string'){
1125 : 1 : for(let day of this.#weatherData.days){
1126 : 1 : if(day.datetime === dayInfo){
1127 : 1 : day.tempmax = value;
1128 : 1 : break;
1129 : 1 : }
1130 : 1 : }
1131 [ + ]: 1 : }
1132 : 2 : else
1133 [ + ]: 2 : if(typeof dayInfo === 'number'){
1134 : 1 : let day = this.#weatherData.days[dayInfo];
1135 : 1 : if(day) day.tempmax = value;
1136 : 1 : }
1137 : 1 : else{
1138 : 1 : throw new TypeError(`Weather.setTempmaxOnDay: Invalid input day value '${dayInfo}'.`);
1139 : 1 : }
1140 : 3 : }
1141 [ + ]: 3 : catch(error){
1142 : 1 : throw error;
1143 : 1 : }
1144 : 3 : }
1145 : 83 :
1146 : 83 : /**
1147 : 83 : * Core Weather Elements
1148 : 83 : *
1149 : 83 : * @method getTempminOnDay
1150 : 83 : * @instance
1151 : 83 : * @memberof module:weather.Weather
1152 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1153 : 83 : * @returns {number|null} The minimum temperature for the specified day, or null if not available or error.
1154 : 83 : * @desc Retrieves the minimum temperature for a specific day identified by date or index.
1155 : 83 : */
1156 [ + ]: 83 : getTempminOnDay(dayInfo){
1157 : 4 : try{
1158 [ + ]: 4 : if(typeof dayInfo === 'string'){
1159 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.tempmin;
1160 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1161 [ + ]: 2 : }
1162 : 2 : else
1163 [ + ]: 2 : if(typeof dayInfo === 'number'){
1164 : 1 : let tmp = this.#weatherData.days[dayInfo]?.tempmin;
1165 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1166 [ + ]: 1 : }
1167 : 1 : else{
1168 : 1 : throw new TypeError(`Weather.getTempminOnDay: Invalid input day value '${dayInfo}'.`);
1169 : 1 : }
1170 : 4 : }
1171 [ + ]: 4 : catch(error){
1172 : 1 : return null;
1173 : 1 : }
1174 : 4 : }
1175 : 83 :
1176 : 83 : /**
1177 : 83 : * Core Weather Elements
1178 : 83 : *
1179 : 83 : * @method setTempminOnDay
1180 : 83 : * @instance
1181 : 83 : * @memberof module:weather.Weather
1182 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1183 : 83 : * @param {number} value - The new minimum temperature value to set.
1184 : 83 : * @desc Sets the minimum temperature for a specific day identified by date or index.
1185 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1186 : 83 : */
1187 [ + ]: 83 : setTempminOnDay(dayInfo, value){
1188 : 3 : try{
1189 [ + ]: 3 : if(typeof dayInfo === 'string'){
1190 : 1 : for(let day of this.#weatherData.days){
1191 : 1 : if(day.datetime === dayInfo){
1192 : 1 : day.tempmin = value;
1193 : 1 : break;
1194 : 1 : }
1195 : 1 : }
1196 [ + ]: 1 : }
1197 : 2 : else
1198 [ + ]: 2 : if(typeof dayInfo === 'number'){
1199 : 1 : let day = this.#weatherData.days[dayInfo];
1200 : 1 : if(day) day.tempmin = value;
1201 : 1 : }
1202 : 1 : else{
1203 : 1 : throw new TypeError(`Weather.setTempminOnDay: Invalid input day value '${dayInfo}'.`);
1204 : 1 : }
1205 : 3 : }
1206 [ + ]: 3 : catch(error){
1207 : 1 : throw error;
1208 : 1 : }
1209 : 3 : }
1210 : 83 :
1211 : 83 : /**
1212 : 83 : * Core Weather Elements
1213 : 83 : *
1214 : 83 : * @method getFeelslikeOnDay
1215 : 83 : * @instance
1216 : 83 : * @memberof module:weather.Weather
1217 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1218 : 83 : * @returns {number|null} The 'feels like' temperature for the specified day, or null if not available or error.
1219 : 83 : * @desc Retrieves the 'feels like' temperature for a specific day identified by date or index.
1220 : 83 : */
1221 [ + ]: 83 : getFeelslikeOnDay(dayInfo){
1222 : 4 : try{
1223 [ + ]: 4 : if(typeof dayInfo === 'string'){
1224 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.feelslike;
1225 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1226 [ + ]: 2 : }
1227 : 2 : else
1228 [ + ]: 2 : if(typeof dayInfo === 'number'){
1229 : 1 : let tmp = this.#weatherData.days[dayInfo]?.feelslike;
1230 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1231 [ + ]: 1 : }
1232 : 1 : else{
1233 : 1 : throw new TypeError(`Weather.getFeelslikeOnDay: Invalid input day value '${dayInfo}'.`);
1234 : 1 : }
1235 : 4 : }
1236 [ + ]: 4 : catch(error){
1237 : 1 : return null;
1238 : 1 : }
1239 : 4 : }
1240 : 83 :
1241 : 83 : /**
1242 : 83 : * Core Weather Elements
1243 : 83 : *
1244 : 83 : * @method setFeelslikeOnDay
1245 : 83 : * @instance
1246 : 83 : * @memberof module:weather.Weather
1247 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1248 : 83 : * @param {number} value - The new 'feels like' temperature value to set.
1249 : 83 : * @desc Sets the 'feels like' temperature for a specific day identified by date or index.
1250 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1251 : 83 : */
1252 [ + ]: 83 : setFeelslikeOnDay(dayInfo, value){
1253 : 3 : try{
1254 [ + ]: 3 : if(typeof dayInfo === 'string'){
1255 : 1 : for(let day of this.#weatherData.days){
1256 : 1 : if(day.datetime === dayInfo){
1257 : 1 : day.feelslike = value;
1258 : 1 : break;
1259 : 1 : }
1260 : 1 : }
1261 [ + ]: 1 : }
1262 : 2 : else
1263 [ + ]: 2 : if(typeof dayInfo === 'number'){
1264 : 1 : let day = this.#weatherData.days[dayInfo];
1265 : 1 : if(day) day.feelslike = value;
1266 : 1 : }
1267 : 1 : else{
1268 : 1 : throw new TypeError(`Weather.setFeelslikeOnDay: Invalid input day value '${dayInfo}'.`);
1269 : 1 : }
1270 : 3 : }
1271 [ + ]: 3 : catch(error){
1272 : 1 : throw error;
1273 : 1 : }
1274 : 3 : }
1275 : 83 :
1276 : 83 : /**
1277 : 83 : * Core Weather Elements
1278 : 83 : *
1279 : 83 : * @method getFeelslikemaxOnDay
1280 : 83 : * @instance
1281 : 83 : * @memberof module:weather.Weather
1282 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1283 : 83 : * @returns {number|null} The maximum 'feels like' temperature for the specified day, or null if not available or error.
1284 : 83 : * @desc Retrieves the maximum 'feels like' temperature for a specific day identified by date or index.
1285 : 83 : */
1286 [ + ]: 83 : getFeelslikemaxOnDay(dayInfo){
1287 : 4 : try{
1288 [ + ]: 4 : if(typeof dayInfo === 'string'){
1289 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.feelslikemax;
1290 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1291 [ + ]: 2 : }
1292 : 2 : else
1293 [ + ]: 2 : if(typeof dayInfo === 'number'){
1294 : 1 : let tmp = this.#weatherData.days[dayInfo]?.feelslikemax;
1295 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1296 [ + ]: 1 : }
1297 : 1 : else{
1298 : 1 : throw new TypeError(`Weather.getFeelslikemaxOnDay: Invalid input day value '${dayInfo}'.`);
1299 : 1 : }
1300 : 4 : }
1301 [ + ]: 4 : catch(error){
1302 : 1 : return null;
1303 : 1 : }
1304 : 4 : }
1305 : 83 :
1306 : 83 : /**
1307 : 83 : * Core Weather Elements
1308 : 83 : *
1309 : 83 : * @method setFeelslikemaxOnDay
1310 : 83 : * @instance
1311 : 83 : * @memberof module:weather.Weather
1312 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1313 : 83 : * @param {number} value - The new maximum 'feels like' temperature value to set.
1314 : 83 : * @desc Sets the maximum 'feels like' temperature for a specific day identified by date or index.
1315 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1316 : 83 : */
1317 [ + ]: 83 : setFeelslikemaxOnDay(dayInfo, value){
1318 : 3 : try{
1319 [ + ]: 3 : if(typeof dayInfo === 'string'){
1320 : 1 : for(let day of this.#weatherData.days){
1321 : 1 : if(day.datetime === dayInfo){
1322 : 1 : day.feelslikemax = value;
1323 : 1 : break;
1324 : 1 : }
1325 : 1 : }
1326 [ + ]: 1 : }
1327 : 2 : else
1328 [ + ]: 2 : if(typeof dayInfo === 'number'){
1329 : 1 : let day = this.#weatherData.days[dayInfo];
1330 : 1 : if(day) day.feelslikemax = value;
1331 : 1 : }
1332 : 1 : else{
1333 : 1 : throw new TypeError(`Weather.setFeelslikemaxOnDay: Invalid input day value '${dayInfo}'.`);
1334 : 1 : }
1335 : 3 : }
1336 [ + ]: 3 : catch(error){
1337 : 1 : throw error;
1338 : 1 : }
1339 : 3 : }
1340 : 83 :
1341 : 83 : /**
1342 : 83 : * Core Weather Elements
1343 : 83 : *
1344 : 83 : * @method getFeelslikeminOnDay
1345 : 83 : * @instance
1346 : 83 : * @memberof module:weather.Weather
1347 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1348 : 83 : * @returns {number|null} The minimum 'feels like' temperature for the specified day, or null if not available or error.
1349 : 83 : * @desc Retrieves the minimum 'feels like' temperature for a specific day identified by date or index.
1350 : 83 : */
1351 [ + ]: 83 : getFeelslikeminOnDay(dayInfo){
1352 : 4 : try{
1353 [ + ]: 4 : if(typeof dayInfo === 'string'){
1354 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.feelslikemin;
1355 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1356 [ + ]: 2 : }
1357 : 2 : else
1358 [ + ]: 2 : if(typeof dayInfo === 'number'){
1359 : 1 : let tmp = this.#weatherData.days[dayInfo]?.feelslikemin;
1360 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1361 [ + ]: 1 : }
1362 : 1 : else{
1363 : 1 : throw new TypeError(`Weather.getFeelslikeminOnDay: Invalid input day value '${dayInfo}'.`);
1364 : 1 : }
1365 : 4 : }
1366 [ + ]: 4 : catch(error){
1367 : 1 : return null;
1368 : 1 : }
1369 : 4 : }
1370 : 83 :
1371 : 83 : /**
1372 : 83 : * Core Weather Elements
1373 : 83 : *
1374 : 83 : * @method setFeelslikeminOnDay
1375 : 83 : * @instance
1376 : 83 : * @memberof module:weather.Weather
1377 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1378 : 83 : * @param {number} value - The new minimum temperature value to set.
1379 : 83 : * @desc Sets the minimum 'feels like' temperature for a specific day identified by date or index.
1380 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1381 : 83 : */
1382 [ + ]: 83 : setFeelslikeminOnDay(dayInfo, value){
1383 : 3 : try{
1384 [ + ]: 3 : if(typeof dayInfo === 'string'){
1385 : 1 : for(let day of this.#weatherData.days){
1386 : 1 : if(day.datetime === dayInfo){
1387 : 1 : day.feelslikemin = value;
1388 : 1 : break;
1389 : 1 : }
1390 : 1 : }
1391 [ + ]: 1 : }
1392 : 2 : else
1393 [ + ]: 2 : if(typeof dayInfo === 'number'){
1394 : 1 : let day = this.#weatherData.days[dayInfo];
1395 : 1 : if(day) day.feelslikemin = value;
1396 : 1 : }
1397 : 1 : else{
1398 : 1 : throw new TypeError(`Weather.setFeelslikeminOnDay: Invalid input day value '${dayInfo}'.`);
1399 : 1 : }
1400 : 3 : }
1401 [ + ]: 3 : catch(error){
1402 : 1 : throw error;
1403 : 1 : }
1404 : 3 : }
1405 : 83 :
1406 : 83 : /**
1407 : 83 : * Core Weather Elements
1408 : 83 : *
1409 : 83 : * @method getDewOnDay
1410 : 83 : * @instance
1411 : 83 : * @memberof module:weather.Weather
1412 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1413 : 83 : * @returns {number|null} The dew point for the specified day, or null if not available or error.
1414 : 83 : * @desc Retrieves the dew point for a specific day identified by date or index.
1415 : 83 : */
1416 [ + ]: 83 : getDewOnDay(dayInfo){
1417 : 4 : try{
1418 [ + ]: 4 : if(typeof dayInfo === 'string'){
1419 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.dew;
1420 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1421 [ + ]: 2 : }
1422 : 2 : else
1423 [ + ]: 2 : if(typeof dayInfo === 'number'){
1424 : 1 : let tmp = this.#weatherData.days[dayInfo]?.dew;
1425 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1426 [ + ]: 1 : }
1427 : 1 : else{
1428 : 1 : throw new TypeError(`Weather.getDewOnDay: Invalid input day value '${dayInfo}'.`);
1429 : 1 : }
1430 : 4 : }
1431 [ + ]: 4 : catch(error){
1432 : 1 : return null;
1433 : 1 : }
1434 : 4 : }
1435 : 83 :
1436 : 83 : /**
1437 : 83 : * Core Weather Elements
1438 : 83 : *
1439 : 83 : * @method setDewOnDay
1440 : 83 : * @instance
1441 : 83 : * @memberof module:weather.Weather
1442 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1443 : 83 : * @param {number} value - The new dew point value to set.
1444 : 83 : * @desc Sets the dew point for a specific day identified by date or index.
1445 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1446 : 83 : */
1447 [ + ]: 83 : setDewOnDay(dayInfo, value){
1448 : 3 : try{
1449 [ + ]: 3 : if(typeof dayInfo === 'string'){
1450 : 1 : for (let day of this.#weatherData.days){
1451 : 1 : if(day.datetime === dayInfo){
1452 : 1 : day.dew = value;
1453 : 1 : break;
1454 : 1 : }
1455 : 1 : }
1456 [ + ]: 1 : }
1457 : 2 : else
1458 [ + ]: 2 : if(typeof dayInfo === 'number'){
1459 : 1 : let day = this.#weatherData.days[dayInfo];
1460 : 1 : if(day) day.dew = value;
1461 : 1 : }
1462 : 1 : else{
1463 : 1 : throw new TypeError(`Weather.setDewOnDay: Invalid input day value '${dayInfo}'.`);
1464 : 1 : }
1465 : 3 : }
1466 [ + ]: 3 : catch(error){
1467 : 1 : throw error;
1468 : 1 : }
1469 : 3 : }
1470 : 83 :
1471 : 83 : /**
1472 : 83 : * Core Weather Elements
1473 : 83 : *
1474 : 83 : * @method getHumidityOnDay
1475 : 83 : * @instance
1476 : 83 : * @memberof module:weather.Weather
1477 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1478 : 83 : * @returns {number|null} The humidity percentage for the specified day, or null if not available or error.
1479 : 83 : * @desc Retrieves the humidity percentage for a specific day identified by date or index.
1480 : 83 : */
1481 [ + ]: 83 : getHumidityOnDay(dayInfo){
1482 : 4 : try{
1483 [ + ]: 4 : if(typeof dayInfo === 'string'){
1484 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.humidity;
1485 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1486 [ + ]: 2 : }
1487 : 2 : else
1488 [ + ]: 2 : if(typeof dayInfo === 'number'){
1489 : 1 : let tmp = this.#weatherData.days[dayInfo]?.humidity;
1490 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1491 [ + ]: 1 : }
1492 : 1 : else{
1493 : 1 : throw new TypeError(`Weather.getHumidityOnDay: Invalid input day value '${dayInfo}'.`);
1494 : 1 : }
1495 : 4 : }
1496 [ + ]: 4 : catch(error){
1497 : 1 : return null;
1498 : 1 : }
1499 : 4 : }
1500 : 83 :
1501 : 83 : /**
1502 : 83 : * Core Weather Elements
1503 : 83 : *
1504 : 83 : * @method setHumidityOnDay
1505 : 83 : * @instance
1506 : 83 : * @memberof module:weather.Weather
1507 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1508 : 83 : * @param {number} value - The new humidity percentage value to set.
1509 : 83 : * @desc Sets the humidity percentage for a specific day identified by date or index.
1510 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1511 : 83 : */
1512 [ + ]: 83 : setHumidityOnDay(dayInfo, value){
1513 : 3 : try{
1514 [ + ]: 3 : if(typeof dayInfo === 'string'){
1515 : 1 : for (let day of this.#weatherData.days){
1516 : 1 : if(day.datetime === dayInfo){
1517 : 1 : day.humidity = value;
1518 : 1 : break;
1519 : 1 : }
1520 : 1 : }
1521 [ + ]: 1 : }
1522 : 2 : else
1523 [ + ]: 2 : if(typeof dayInfo === 'number'){
1524 : 1 : let day = this.#weatherData.days[dayInfo];
1525 : 1 : if(day) day.humidity = value;
1526 : 1 : }
1527 : 1 : else{
1528 : 1 : throw new TypeError(`Weather.setHumidityOnDay: Invalid input day value '${dayInfo}'.`);
1529 : 1 : }
1530 : 3 : }
1531 [ + ]: 3 : catch(error){
1532 : 1 : throw error;
1533 : 1 : }
1534 : 3 : }
1535 : 83 :
1536 : 83 : /**
1537 : 83 : * Core Weather Elements
1538 : 83 : *
1539 : 83 : * @method getPrecipOnDay
1540 : 83 : * @instance
1541 : 83 : * @memberof module:weather.Weather
1542 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1543 : 83 : * @returns {number|null} The precipitation amount for the specified day, or null if not available or error.
1544 : 83 : * @desc Retrieves the precipitation amount for a specific day identified by date or index.
1545 : 83 : */
1546 [ + ]: 83 : getPrecipOnDay(dayInfo){
1547 : 4 : try{
1548 [ + ]: 4 : if(typeof dayInfo === 'string'){
1549 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.precip;
1550 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1551 [ + ]: 2 : }
1552 : 2 : else
1553 [ + ]: 2 : if(typeof dayInfo === 'number'){
1554 : 1 : let tmp = this.#weatherData.days[dayInfo]?.precip;
1555 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1556 [ + ]: 1 : }
1557 : 1 : else{
1558 : 1 : throw new TypeError(`Weather.getPrecipOnDay: Invalid input day value '${dayInfo}'.`);
1559 : 1 : }
1560 : 4 : }
1561 [ + ]: 4 : catch(error){
1562 : 1 : return null;
1563 : 1 : }
1564 : 4 : }
1565 : 83 :
1566 : 83 : /**
1567 : 83 : * Core Weather Elements
1568 : 83 : *
1569 : 83 : * @method setPrecipOnDay
1570 : 83 : * @instance
1571 : 83 : * @memberof module:weather.Weather
1572 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1573 : 83 : * @param {number} value - The new precipitation amount value to set.
1574 : 83 : * @desc Sets the precipitation amount for a specific day identified by date or index.
1575 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1576 : 83 : */
1577 [ + ]: 83 : setPrecipOnDay(dayInfo, value){
1578 : 3 : try{
1579 [ + ]: 3 : if(typeof dayInfo === 'string'){
1580 : 1 : for (let day of this.#weatherData.days){
1581 : 1 : if(day.datetime === dayInfo){
1582 : 1 : day.precip = value;
1583 : 1 : break;
1584 : 1 : }
1585 : 1 : }
1586 [ + ]: 1 : }
1587 : 2 : else
1588 [ + ]: 2 : if(typeof dayInfo === 'number'){
1589 : 1 : let day = this.#weatherData.days[dayInfo];
1590 : 1 : if(day) day.precip = value;
1591 : 1 : }
1592 : 1 : else{
1593 : 1 : throw new TypeError(`Weather.setPrecipOnDay: Invalid input day value '${dayInfo}'.`);
1594 : 1 : }
1595 : 3 : }
1596 [ + ]: 3 : catch(error){
1597 : 1 : throw error;
1598 : 1 : }
1599 : 3 : }
1600 : 83 :
1601 : 83 : /**
1602 : 83 : * Core Weather Elements
1603 : 83 : *
1604 : 83 : * @method getPrecipprobOnDay
1605 : 83 : * @instance
1606 : 83 : * @memberof module:weather.Weather
1607 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1608 : 83 : * @returns {number|null} The probability of precipitation for the specified day, or null if not available or error.
1609 : 83 : * @desc Retrieves the probability of precipitation for a specific day identified by date or index.
1610 : 83 : */
1611 [ + ]: 83 : getPrecipprobOnDay(dayInfo){
1612 : 4 : try{
1613 [ + ]: 4 : if(typeof dayInfo === 'string'){
1614 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.precipprob;
1615 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1616 [ + ]: 2 : }
1617 : 2 : else
1618 [ + ]: 2 : if(typeof dayInfo === 'number'){
1619 : 1 : let tmp = this.#weatherData.days[dayInfo]?.precipprob;
1620 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1621 [ + ]: 1 : }
1622 : 1 : else{
1623 : 1 : throw new TypeError(`Weather.getPrecipprobOnDay: Invalid input day value '${dayInfo}'.`);
1624 : 1 : }
1625 : 4 : }
1626 [ + ]: 4 : catch(error){
1627 : 1 : return null;
1628 : 1 : }
1629 : 4 : }
1630 : 83 :
1631 : 83 : /**
1632 : 83 : * Core Weather Elements
1633 : 83 : *
1634 : 83 : * @method setPrecipprobOnDay
1635 : 83 : * @instance
1636 : 83 : * @memberof module:weather.Weather
1637 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1638 : 83 : * @param {number} value - The new probability of precipitation value to set.
1639 : 83 : * @desc Sets the probability of precipitation for a specific day identified by date or index.
1640 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1641 : 83 : */
1642 [ + ]: 83 : setPrecipprobOnDay(dayInfo, value){
1643 : 3 : try{
1644 [ + ]: 3 : if(typeof dayInfo === 'string'){
1645 : 1 : for (let day of this.#weatherData.days){
1646 : 1 : if(day.datetime === dayInfo){
1647 : 1 : day.precipprob = value;
1648 : 1 : break;
1649 : 1 : }
1650 : 1 : }
1651 [ + ]: 1 : }
1652 : 2 : else
1653 [ + ]: 2 : if(typeof dayInfo === 'number'){
1654 : 1 : let day = this.#weatherData.days[dayInfo];
1655 : 1 : if(day) day.precipprob = value;
1656 : 1 : }
1657 : 1 : else{
1658 : 1 : throw new TypeError(`Weather.setPrecipprobOnDay: Invalid input day value '${dayInfo}'.`);
1659 : 1 : }
1660 : 3 : }
1661 [ + ]: 3 : catch(error){
1662 : 1 : throw error;
1663 : 1 : }
1664 : 3 : }
1665 : 83 :
1666 : 83 : /**
1667 : 83 : * Core Weather Elements
1668 : 83 : *
1669 : 83 : * @method getPrecipcoverOnDay
1670 : 83 : * @instance
1671 : 83 : * @memberof module:weather.Weather
1672 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1673 : 83 : * @returns {number|null} The precipitation coverage for the specified day, or null if not available or error.
1674 : 83 : * @desc Retrieves the precipitation coverage for a specific day identified by date or index.
1675 : 83 : */
1676 [ + ]: 83 : getPrecipcoverOnDay(dayInfo){
1677 : 4 : try{
1678 [ + ]: 4 : if(typeof dayInfo === 'string'){
1679 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.precipcover;
1680 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1681 [ + ]: 2 : }
1682 : 2 : else
1683 [ + ]: 2 : if(typeof dayInfo === 'number'){
1684 : 1 : let tmp = this.#weatherData.days[dayInfo]?.precipcover;
1685 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1686 [ + ]: 1 : }
1687 : 1 : else{
1688 : 1 : throw new TypeError(`Weather.getPrecipcoverOnDay: Invalid input day value '${dayInfo}'.`);
1689 : 1 : }
1690 : 4 : }
1691 [ + ]: 4 : catch(error){
1692 : 1 : return null;
1693 : 1 : }
1694 : 4 : }
1695 : 83 :
1696 : 83 : /**
1697 : 83 : * Core Weather Elements
1698 : 83 : *
1699 : 83 : * @method setPrecipcoverOnDay
1700 : 83 : * @instance
1701 : 83 : * @memberof module:weather.Weather
1702 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1703 : 83 : * @param {number} value - The new precipitation coverage value to set.
1704 : 83 : * @desc Sets the precipitation coverage for a specific day identified by date or index.
1705 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1706 : 83 : */
1707 [ + ]: 83 : setPrecipcoverOnDay(dayInfo, value){
1708 : 3 : try{
1709 [ + ]: 3 : if(typeof dayInfo === 'string'){
1710 : 1 : for (let day of this.#weatherData.days){
1711 : 1 : if(day.datetime === dayInfo){
1712 : 1 : day.precipcover = value;
1713 : 1 : break;
1714 : 1 : }
1715 : 1 : }
1716 [ + ]: 1 : }
1717 : 2 : else
1718 [ + ]: 2 : if(typeof dayInfo === 'number'){
1719 : 1 : let day = this.#weatherData.days[dayInfo];
1720 : 1 : if(day) day.precipcover = value;
1721 : 1 : }
1722 : 1 : else{
1723 : 1 : throw new TypeError(`Weather.setPrecipcoverOnDay: Invalid input day value '${dayInfo}'.`);
1724 : 1 : }
1725 : 3 : }
1726 [ + ]: 3 : catch(error){
1727 : 1 : throw error;
1728 : 1 : }
1729 : 3 : }
1730 : 83 :
1731 : 83 : /**
1732 : 83 : * Core Weather Elements
1733 : 83 : *
1734 : 83 : * @method getPreciptypeOnDay
1735 : 83 : * @instance
1736 : 83 : * @memberof module:weather.Weather
1737 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1738 : 83 : * @returns {string|null} The type of precipitation for the specified day, or null if not available or error.
1739 : 83 : * @desc Retrieves the type of precipitation for a specific day identified by date or index.
1740 : 83 : */
1741 [ + ]: 83 : getPreciptypeOnDay(dayInfo){
1742 : 4 : try{
1743 [ + ]: 4 : if(typeof dayInfo === 'string'){
1744 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.preciptype;
1745 [ - ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1746 [ + ]: 2 : }
1747 : 2 : else
1748 [ + ]: 2 : if(typeof dayInfo === 'number'){
1749 : 1 : let tmp = this.#weatherData.days[dayInfo]?.preciptype;
1750 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1751 [ + ]: 1 : }
1752 : 1 : else{
1753 : 1 : throw new TypeError(`Weather.getPreciptypeOnDay: Invalid input day value '${dayInfo}'.`);
1754 : 1 : }
1755 : 4 : }
1756 [ + ]: 4 : catch(error){
1757 : 1 : return null;
1758 : 1 : }
1759 : 4 : }
1760 : 83 :
1761 : 83 : /**
1762 : 83 : * Core Weather Elements
1763 : 83 : *
1764 : 83 : * @method setPreciptypeOnDay
1765 : 83 : * @instance
1766 : 83 : * @memberof module:weather.Weather
1767 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1768 : 83 : * @param {string} value - The new type of precipitation value to set.
1769 : 83 : * @desc Sets the type of precipitation for a specific day identified by date or index.
1770 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1771 : 83 : */
1772 [ + ]: 83 : setPreciptypeOnDay(dayInfo, value){
1773 : 3 : try{
1774 [ + ]: 3 : if(typeof dayInfo === 'string'){
1775 : 1 : for (let day of this.#weatherData.days){
1776 : 1 : if(day.datetime === dayInfo){
1777 : 1 : day.preciptype = value;
1778 : 1 : break;
1779 : 1 : }
1780 : 1 : }
1781 [ + ]: 1 : }
1782 : 2 : else
1783 [ + ]: 2 : if(typeof dayInfo === 'number'){
1784 : 1 : let day = this.#weatherData.days[dayInfo];
1785 : 1 : if(day) day.preciptype = value;
1786 : 1 : }
1787 : 1 : else{
1788 : 1 : throw new TypeError(`Weather.setPreciptypeOnDay: Invalid input day value '${dayInfo}'.`);
1789 : 1 : }
1790 : 3 : }
1791 [ + ]: 3 : catch(error){
1792 : 1 : throw error;
1793 : 1 : }
1794 : 3 : }
1795 : 83 :
1796 : 83 : /**
1797 : 83 : * Core Weather Elements
1798 : 83 : *
1799 : 83 : * @method getSnowOnDay
1800 : 83 : * @instance
1801 : 83 : * @memberof module:weather.Weather
1802 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1803 : 83 : * @returns {number|null} The snowfall amount for the specified day, or null if not available or error.
1804 : 83 : * @desc Retrieves the snowfall amount for a specific day identified by date or index.
1805 : 83 : */
1806 [ + ]: 83 : getSnowOnDay(dayInfo){
1807 : 4 : try{
1808 [ + ]: 4 : if(typeof dayInfo === 'string'){
1809 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.snow;
1810 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1811 [ + ]: 2 : }
1812 : 2 : else
1813 [ + ]: 2 : if(typeof dayInfo === 'number'){
1814 : 1 : let tmp = this.#weatherData.days[dayInfo]?.snow;
1815 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1816 [ + ]: 1 : }
1817 : 1 : else{
1818 : 1 : throw new TypeError(`Weather.getSnowOnDay: Invalid input day value '${dayInfo}'.`);
1819 : 1 : }
1820 : 4 : }
1821 [ + ]: 4 : catch(error){
1822 : 1 : return null;
1823 : 1 : }
1824 : 4 : }
1825 : 83 :
1826 : 83 : /**
1827 : 83 : * Core Weather Elements
1828 : 83 : *
1829 : 83 : * @method setSnowOnDay
1830 : 83 : * @instance
1831 : 83 : * @memberof module:weather.Weather
1832 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1833 : 83 : * @param {number} value - The new snowfall amount to set.
1834 : 83 : * @desc Sets the snowfall amount for a specific day identified by date or index.
1835 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1836 : 83 : */
1837 [ + ]: 83 : setSnowOnDay(dayInfo, value){
1838 : 3 : try{
1839 [ + ]: 3 : if(typeof dayInfo === 'string'){
1840 : 1 : for (let day of this.#weatherData.days){
1841 : 1 : if(day.datetime === dayInfo){
1842 : 1 : day.snow = value;
1843 : 1 : break;
1844 : 1 : }
1845 : 1 : }
1846 [ + ]: 1 : }
1847 : 2 : else
1848 [ + ]: 2 : if(typeof dayInfo === 'number'){
1849 : 1 : let day = this.#weatherData.days[dayInfo];
1850 : 1 : if(day) day.snow = value;
1851 : 1 : }
1852 : 1 : else{
1853 : 1 : throw new TypeError(`Weather.setSnowOnDay: Invalid input day value '${dayInfo}'.`);
1854 : 1 : }
1855 : 3 : }
1856 [ + ]: 3 : catch(error){
1857 : 1 : throw error;
1858 : 1 : }
1859 : 3 : }
1860 : 83 :
1861 : 83 : /**
1862 : 83 : * Core Weather Elements
1863 : 83 : *
1864 : 83 : * @method getSnowdepthOnDay
1865 : 83 : * @instance
1866 : 83 : * @memberof module:weather.Weather
1867 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1868 : 83 : * @returns {number|null} The snow depth for the specified day, or null if not available or error.
1869 : 83 : * @desc Retrieves the snow depth for a specific day identified by date or index.
1870 : 83 : */
1871 [ + ]: 83 : getSnowdepthOnDay(dayInfo){
1872 : 4 : try{
1873 [ + ]: 4 : if(typeof dayInfo === 'string'){
1874 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.snowdepth;
1875 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1876 [ + ]: 2 : }
1877 : 2 : else
1878 [ + ]: 2 : if(typeof dayInfo === 'number'){
1879 : 1 : let tmp = this.#weatherData.days[dayInfo]?.snowdepth;
1880 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1881 [ + ]: 1 : }
1882 : 1 : else{
1883 : 1 : throw new TypeError(`Weather.getSnowdepthOnDay: Invalid input day value '${dayInfo}'.`);
1884 : 1 : }
1885 : 4 : }
1886 [ + ]: 4 : catch(error){
1887 : 1 : return null;
1888 : 1 : }
1889 : 4 : }
1890 : 83 :
1891 : 83 : /**
1892 : 83 : * Core Weather Elements
1893 : 83 : *
1894 : 83 : * @method setSnowdepthOnDay
1895 : 83 : * @instance
1896 : 83 : * @memberof module:weather.Weather
1897 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1898 : 83 : * @param {number} value - The new snow depth to set.
1899 : 83 : * @desc Sets the snow depth for a specific day identified by date or index.
1900 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1901 : 83 : */
1902 [ + ]: 83 : setSnowdepthOnDay(dayInfo, value){
1903 : 3 : try{
1904 [ + ]: 3 : if(typeof dayInfo === 'string'){
1905 : 1 : for (let day of this.#weatherData.days){
1906 : 1 : if(day.datetime === dayInfo){
1907 : 1 : day.snowdepth = value;
1908 : 1 : break;
1909 : 1 : }
1910 : 1 : }
1911 [ + ]: 1 : }
1912 : 2 : else
1913 [ + ]: 2 : if(typeof dayInfo === 'number'){
1914 : 1 : let day = this.#weatherData.days[dayInfo];
1915 : 1 : if(day) day.snowdepth = value;
1916 : 1 : }
1917 : 1 : else{
1918 : 1 : throw new TypeError(`Weather.setSnowdepthOnDay: Invalid input day value '${dayInfo}'.`);
1919 : 1 : }
1920 : 3 : }
1921 [ + ]: 3 : catch(error){
1922 : 1 : throw error;
1923 : 1 : }
1924 : 3 : }
1925 : 83 :
1926 : 83 : /**
1927 : 83 : * Core Weather Elements
1928 : 83 : *
1929 : 83 : * @method getWindgustOnDay
1930 : 83 : * @instance
1931 : 83 : * @memberof module:weather.Weather
1932 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1933 : 83 : * @returns {number|null} The wind gust value for the specified day, or null if not available or error.
1934 : 83 : * @desc Retrieves the wind gust value for a specific day identified by date or index.
1935 : 83 : */
1936 [ + ]: 83 : getWindgustOnDay(dayInfo){
1937 : 4 : try{
1938 [ + ]: 4 : if(typeof dayInfo === 'string'){
1939 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.windgust;
1940 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
1941 [ + ]: 2 : }
1942 : 2 : else
1943 [ + ]: 2 : if(typeof dayInfo === 'number'){
1944 : 1 : let tmp = this.#weatherData.days[dayInfo]?.windgust;
1945 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
1946 [ + ]: 1 : }
1947 : 1 : else{
1948 : 1 : throw new TypeError(`Weather.getWindgustOnDay: Invalid input day value '${dayInfo}'.`);
1949 : 1 : }
1950 : 4 : }
1951 [ + ]: 4 : catch(error){
1952 : 1 : return null;
1953 : 1 : }
1954 : 4 : }
1955 : 83 :
1956 : 83 : /**
1957 : 83 : * Core Weather Elements
1958 : 83 : *
1959 : 83 : * @method setWindgustOnDay
1960 : 83 : * @instance
1961 : 83 : * @memberof module:weather.Weather
1962 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1963 : 83 : * @param {number} value - The new wind gust value to set.
1964 : 83 : * @desc Sets the wind gust value for a specific day identified by date or index.
1965 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
1966 : 83 : */
1967 [ + ]: 83 : setWindgustOnDay(dayInfo, value){
1968 : 3 : try{
1969 [ + ]: 3 : if(typeof dayInfo === 'string'){
1970 : 1 : for (let day of this.#weatherData.days){
1971 : 1 : if(day.datetime === dayInfo){
1972 : 1 : day.windgust = value;
1973 : 1 : break;
1974 : 1 : }
1975 : 1 : }
1976 [ + ]: 1 : }
1977 : 2 : else
1978 [ + ]: 2 : if(typeof dayInfo === 'number'){
1979 : 1 : let day = this.#weatherData.days[dayInfo];
1980 : 1 : if(day) day.windgust = value;
1981 : 1 : }
1982 : 1 : else{
1983 : 1 : throw new TypeError(`Weather.setWindgustOnDay: Invalid input day value '${dayInfo}'.`);
1984 : 1 : }
1985 : 3 : }
1986 [ + ]: 3 : catch(error){
1987 : 1 : throw error;
1988 : 1 : }
1989 : 3 : }
1990 : 83 :
1991 : 83 : /**
1992 : 83 : * Core Weather Elements
1993 : 83 : *
1994 : 83 : * @method getWindspeedOnDay
1995 : 83 : * @instance
1996 : 83 : * @memberof module:weather.Weather
1997 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
1998 : 83 : * @returns {number|null} The wind speed for the specified day, or null if not available or error.
1999 : 83 : * @desc Retrieves the wind speed for a specific day identified by date or index.
2000 : 83 : */
2001 [ + ]: 83 : getWindspeedOnDay(dayInfo){
2002 : 4 : try{
2003 [ + ]: 4 : if(typeof dayInfo === 'string'){
2004 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.windspeed;
2005 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2006 [ + ]: 2 : }
2007 : 2 : else
2008 [ + ]: 2 : if(typeof dayInfo === 'number'){
2009 : 1 : let tmp = this.#weatherData.days[dayInfo]?.windspeed;
2010 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2011 [ + ]: 1 : }
2012 : 1 : else{
2013 : 1 : throw new TypeError(`Weather.getWindspeedOnDay: Invalid input day value '${dayInfo}'.`);
2014 : 1 : }
2015 : 4 : }
2016 [ + ]: 4 : catch(error){
2017 : 1 : return null;
2018 : 1 : }
2019 : 4 : }
2020 : 83 :
2021 : 83 : /**
2022 : 83 : * Core Weather Elements
2023 : 83 : *
2024 : 83 : * @method setWindspeedOnDay
2025 : 83 : * @instance
2026 : 83 : * @memberof module:weather.Weather
2027 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2028 : 83 : * @param {number} value - The new wind speed value to set.
2029 : 83 : * @desc Sets the wind speed for a specific day identified by date or index.
2030 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2031 : 83 : */
2032 [ + ]: 83 : setWindspeedOnDay(dayInfo, value){
2033 : 3 : try{
2034 [ + ]: 3 : if(typeof dayInfo === 'string'){
2035 : 1 : for (let day of this.#weatherData.days){
2036 : 1 : if(day.datetime === dayInfo){
2037 : 1 : day.windspeed = value;
2038 : 1 : break;
2039 : 1 : }
2040 : 1 : }
2041 [ + ]: 1 : }
2042 : 2 : else
2043 [ + ]: 2 : if(typeof dayInfo === 'number'){
2044 : 1 : let day = this.#weatherData.days[dayInfo];
2045 : 1 : if(day) day.windspeed = value;
2046 : 1 : }
2047 : 1 : else{
2048 : 1 : throw new TypeError(`Weather.setWindspeedOnDay: Invalid input day value '${dayInfo}'.`);
2049 : 1 : }
2050 : 3 : }
2051 [ + ]: 3 : catch(error){
2052 : 1 : throw error;
2053 : 1 : }
2054 : 3 : }
2055 : 83 :
2056 : 83 : /**
2057 : 83 : * Core Weather Elements
2058 : 83 : *
2059 : 83 : * @method getWinddirOnDay
2060 : 83 : * @instance
2061 : 83 : * @memberof module:weather.Weather
2062 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2063 : 83 : * @returns {number|null} The wind direction for the specified day, or null if not available or error.
2064 : 83 : * @desc Retrieves the wind direction for a specific day identified by date or index.
2065 : 83 : */
2066 [ + ]: 83 : getWinddirOnDay(dayInfo){
2067 : 4 : try{
2068 [ + ]: 4 : if(typeof dayInfo === 'string'){
2069 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.winddir;
2070 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2071 [ + ]: 2 : }
2072 : 2 : else
2073 [ + ]: 2 : if(typeof dayInfo === 'number'){
2074 : 1 : let tmp = this.#weatherData.days[dayInfo]?.winddir;
2075 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2076 [ + ]: 1 : }
2077 : 1 : else{
2078 : 1 : throw new TypeError(`Weather.getWinddirOnDay: Invalid input day value '${dayInfo}'.`);
2079 : 1 : }
2080 : 4 : }
2081 [ + ]: 4 : catch(error){
2082 : 1 : return null;
2083 : 1 : }
2084 : 4 : }
2085 : 83 :
2086 : 83 : /**
2087 : 83 : * Core Weather Elements
2088 : 83 : *
2089 : 83 : * @method setWinddirOnDay
2090 : 83 : * @instance
2091 : 83 : * @memberof module:weather.Weather
2092 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2093 : 83 : * @param {number} value - The new wind direction value to set.
2094 : 83 : * @desc Sets the wind direction for a specific day identified by date or index.
2095 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2096 : 83 : */
2097 [ + ]: 83 : setWinddirOnDay(dayInfo, value){
2098 : 3 : try{
2099 [ + ]: 3 : if(typeof dayInfo === 'string'){
2100 : 1 : for (let day of this.#weatherData.days){
2101 : 1 : if(day.datetime === dayInfo){
2102 : 1 : day.winddir = value;
2103 : 1 : break;
2104 : 1 : }
2105 : 1 : }
2106 [ + ]: 1 : }
2107 : 2 : else
2108 [ + ]: 2 : if(typeof dayInfo === 'number'){
2109 : 1 : let day = this.#weatherData.days[dayInfo];
2110 : 1 : if(day) day.winddir = value;
2111 : 1 : }
2112 : 1 : else{
2113 : 1 : throw new TypeError(`Weather.setWinddirOnDay: Invalid input day value '${dayInfo}'.`);
2114 : 1 : }
2115 : 3 : }
2116 [ + ]: 3 : catch(error){
2117 : 1 : throw error;
2118 : 1 : }
2119 : 3 : }
2120 : 83 :
2121 : 83 : /**
2122 : 83 : * Core Weather Elements
2123 : 83 : *
2124 : 83 : * @method getPressureOnDay
2125 : 83 : * @instance
2126 : 83 : * @memberof module:weather.Weather
2127 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2128 : 83 : * @returns {number|null} The atmospheric pressure for the specified day, or null if not available or error.
2129 : 83 : * @desc Retrieves the atmospheric pressure for a specific day identified by date or index.
2130 : 83 : */
2131 [ + ]: 83 : getPressureOnDay(dayInfo){
2132 : 4 : try{
2133 [ + ]: 4 : if(typeof dayInfo === 'string'){
2134 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.pressure;
2135 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2136 [ + ]: 2 : }
2137 : 2 : else
2138 [ + ]: 2 : if(typeof dayInfo === 'number'){
2139 : 1 : let tmp = this.#weatherData.days[dayInfo]?.pressure;
2140 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2141 [ + ]: 1 : }
2142 : 1 : else{
2143 : 1 : throw new TypeError(`Weather.getPressureOnDay: Invalid input day value '${dayInfo}'.`);
2144 : 1 : }
2145 : 4 : }
2146 [ + ]: 4 : catch(error){
2147 : 1 : return null;
2148 : 1 : }
2149 : 4 : }
2150 : 83 :
2151 : 83 : /**
2152 : 83 : * Core Weather Elements
2153 : 83 : *
2154 : 83 : * @method setPressureOnDay
2155 : 83 : * @instance
2156 : 83 : * @memberof module:weather.Weather
2157 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2158 : 83 : * @param {number} value - The new pressure value to set.
2159 : 83 : * @desc Sets the atmospheric pressure for a specific day identified by date or index.
2160 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2161 : 83 : */
2162 [ + ]: 83 : setPressureOnDay(dayInfo, value){
2163 : 3 : try{
2164 [ + ]: 3 : if(typeof dayInfo === 'string'){
2165 : 1 : for (let day of this.#weatherData.days){
2166 : 1 : if(day.datetime === dayInfo){
2167 : 1 : day.pressure = value;
2168 : 1 : break;
2169 : 1 : }
2170 : 1 : }
2171 [ + ]: 1 : }
2172 : 2 : else
2173 [ + ]: 2 : if(typeof dayInfo === 'number'){
2174 : 1 : let day = this.#weatherData.days[dayInfo];
2175 : 1 : if(day) day.pressure = value;
2176 : 1 : }
2177 : 1 : else{
2178 : 1 : throw new TypeError(`Weather.setPressureOnDay: Invalid input day value '${dayInfo}'.`);
2179 : 1 : }
2180 : 3 : }
2181 [ + ]: 3 : catch(error){
2182 : 1 : throw error;
2183 : 1 : }
2184 : 3 : }
2185 : 83 :
2186 : 83 : /**
2187 : 83 : * Core Weather Elements
2188 : 83 : *
2189 : 83 : * @method getCloudcoverOnDay
2190 : 83 : * @instance
2191 : 83 : * @memberof module:weather.Weather
2192 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2193 : 83 : * @returns {number|null} The cloud cover percentage for the specified day, or null if not available or error.
2194 : 83 : * @desc Retrieves the cloud cover percentage for a specific day identified by date or index.
2195 : 83 : */
2196 [ + ]: 83 : getCloudcoverOnDay(dayInfo){
2197 : 4 : try{
2198 [ + ]: 4 : if(typeof dayInfo === 'string'){
2199 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.cloudcover;
2200 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2201 [ + ]: 2 : }
2202 : 2 : else
2203 [ + ]: 2 : if(typeof dayInfo === 'number'){
2204 : 1 : let tmp = this.#weatherData.days[dayInfo]?.cloudcover;
2205 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2206 [ + ]: 1 : }
2207 : 1 : else{
2208 : 1 : throw new TypeError(`Weather.getCloudcoverOnDay: Invalid input day value '${dayInfo}'.`);
2209 : 1 : }
2210 : 4 : }
2211 [ + ]: 4 : catch(error){
2212 : 1 : return null;
2213 : 1 : }
2214 : 4 : }
2215 : 83 :
2216 : 83 : /**
2217 : 83 : * Core Weather Elements
2218 : 83 : *
2219 : 83 : * @method setCloudcoverOnDay
2220 : 83 : * @instance
2221 : 83 : * @memberof module:weather.Weather
2222 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2223 : 83 : * @param {number} value - The new cloud cover percentage to set.
2224 : 83 : * @desc Sets the cloud cover percentage for a specific day identified by date or index.
2225 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2226 : 83 : */
2227 [ + ]: 83 : setCloudcoverOnDay(dayInfo, value){
2228 : 3 : try{
2229 [ + ]: 3 : if(typeof dayInfo === 'string'){
2230 : 1 : for (let day of this.#weatherData.days){
2231 : 1 : if(day.datetime === dayInfo){
2232 : 1 : day.cloudcover = value;
2233 : 1 : break;
2234 : 1 : }
2235 : 1 : }
2236 [ + ]: 1 : }
2237 : 2 : else
2238 [ + ]: 2 : if(typeof dayInfo === 'number'){
2239 : 1 : let day = this.#weatherData.days[dayInfo];
2240 : 1 : if(day) day.cloudcover = value;
2241 : 1 : }
2242 : 1 : else{
2243 : 1 : throw new TypeError(`Weather.setCloudcoverOnDay: Invalid input day value '${dayInfo}'.`);
2244 : 1 : }
2245 : 3 : }
2246 [ + ]: 3 : catch(error){
2247 : 1 : throw error;
2248 : 1 : }
2249 : 3 : }
2250 : 83 :
2251 : 83 : /**
2252 : 83 : * Core Weather Elements
2253 : 83 : *
2254 : 83 : * @method getVisibilityOnDay
2255 : 83 : * @instance
2256 : 83 : * @memberof module:weather.Weather
2257 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2258 : 83 : * @returns {number|null} The visibility distance for the specified day, or null if not available or error.
2259 : 83 : * @desc Retrieves the visibility distance for a specific day identified by date or index.
2260 : 83 : */
2261 [ + ]: 83 : getVisibilityOnDay(dayInfo){
2262 : 4 : try{
2263 [ + ]: 4 : if(typeof dayInfo === 'string'){
2264 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.visibility;
2265 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2266 [ + ]: 2 : }
2267 : 2 : else
2268 [ + ]: 2 : if(typeof dayInfo === 'number'){
2269 : 1 : let tmp = this.#weatherData.days[dayInfo]?.visibility;
2270 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2271 [ + ]: 1 : }
2272 : 1 : else{
2273 : 1 : throw new TypeError(`Weather.getVisibilityOnDay: Invalid input day value '${dayInfo}'.`);
2274 : 1 : }
2275 : 4 : }
2276 [ + ]: 4 : catch(error){
2277 : 1 : return null;
2278 : 1 : }
2279 : 4 : }
2280 : 83 :
2281 : 83 : /**
2282 : 83 : * Core Weather Elements
2283 : 83 : *
2284 : 83 : * @method setVisibilityOnDay
2285 : 83 : * @instance
2286 : 83 : * @memberof module:weather.Weather
2287 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2288 : 83 : * @param {number} value - The new visibility distance to set.
2289 : 83 : * @desc Sets the visibility distance for a specific day identified by date or index.
2290 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2291 : 83 : */
2292 [ + ]: 83 : setVisibilityOnDay(dayInfo, value){
2293 : 3 : try{
2294 [ + ]: 3 : if(typeof dayInfo === 'string'){
2295 : 1 : for (let day of this.#weatherData.days){
2296 : 1 : if(day.datetime === dayInfo){
2297 : 1 : day.visibility = value;
2298 : 1 : break;
2299 : 1 : }
2300 : 1 : }
2301 [ + ]: 1 : }
2302 : 2 : else
2303 [ + ]: 2 : if(typeof dayInfo === 'number'){
2304 : 1 : let day = this.#weatherData.days[dayInfo];
2305 : 1 : if(day) day.visibility = value;
2306 : 1 : }
2307 : 1 : else{
2308 : 1 : throw new TypeError(`Weather.setVisibilityOnDay: Invalid input day value '${dayInfo}'.`);
2309 : 1 : }
2310 : 3 : }
2311 [ + ]: 3 : catch(error){
2312 : 1 : throw error;
2313 : 1 : }
2314 : 3 : }
2315 : 83 :
2316 : 83 : /**
2317 : 83 : * Core Weather Elements
2318 : 83 : *
2319 : 83 : * @method getSolarradiationOnDay
2320 : 83 : * @instance
2321 : 83 : * @memberof module:weather.Weather
2322 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2323 : 83 : * @returns {number|null} The solar radiation level for the specified day, or null if not available or error.
2324 : 83 : * @desc Retrieves the solar radiation level for a specific day identified by date or index.
2325 : 83 : */
2326 [ + ]: 83 : getSolarradiationOnDay(dayInfo){
2327 : 4 : try{
2328 [ + ]: 4 : if(typeof dayInfo === 'string'){
2329 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.solarradiation;
2330 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2331 [ + ]: 2 : }
2332 : 2 : else
2333 [ + ]: 2 : if(typeof dayInfo === 'number'){
2334 : 1 : let tmp = this.#weatherData.days[dayInfo]?.solarradiation;
2335 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2336 [ + ]: 1 : }
2337 : 1 : else{
2338 : 1 : throw new TypeError(`Weather.getSolarradiationOnDay: Invalid input day value '${dayInfo}'.`);
2339 : 1 : }
2340 : 4 : }
2341 [ + ]: 4 : catch(error){
2342 : 1 : return null;
2343 : 1 : }
2344 : 4 : }
2345 : 83 :
2346 : 83 : /**
2347 : 83 : * Core Weather Elements
2348 : 83 : *
2349 : 83 : * @method setSolarradiationOnDay
2350 : 83 : * @instance
2351 : 83 : * @memberof module:weather.Weather
2352 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2353 : 83 : * @param {number} value - The new solar radiation level to set.
2354 : 83 : * @desc Sets the solar radiation level for a specific day identified by date or index.
2355 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2356 : 83 : */
2357 [ + ]: 83 : setSolarradiationOnDay(dayInfo, value){
2358 : 3 : try{
2359 [ + ]: 3 : if(typeof dayInfo === 'string'){
2360 : 1 : for (let day of this.#weatherData.days){
2361 : 1 : if(day.datetime === dayInfo){
2362 : 1 : day.solarradiation = value;
2363 : 1 : break;
2364 : 1 : }
2365 : 1 : }
2366 [ + ]: 1 : }
2367 : 2 : else
2368 [ + ]: 2 : if(typeof dayInfo === 'number'){
2369 : 1 : let day = this.#weatherData.days[dayInfo];
2370 : 1 : if(day) day.solarradiation = value;
2371 : 1 : }
2372 : 1 : else{
2373 : 1 : throw new TypeError(`Weather.setSolarradiationOnDay: Invalid input day value '${dayInfo}'.`);
2374 : 1 : }
2375 : 3 : }
2376 [ + ]: 3 : catch(error){
2377 : 1 : throw error;
2378 : 1 : }
2379 : 3 : }
2380 : 83 :
2381 : 83 : /**
2382 : 83 : * Core Weather Elements
2383 : 83 : *
2384 : 83 : * @method getSolarenergyOnDay
2385 : 83 : * @instance
2386 : 83 : * @memberof module:weather.Weather
2387 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2388 : 83 : * @returns {number|null} The solar energy generated on the specified day, or null if not available or error.
2389 : 83 : * @desc Retrieves the solar energy generated on a specific day identified by date or index.
2390 : 83 : */
2391 [ + ]: 83 : getSolarenergyOnDay(dayInfo){
2392 : 4 : try{
2393 [ + ]: 4 : if(typeof dayInfo === 'string'){
2394 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.solarenergy;
2395 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2396 [ + ]: 2 : }
2397 : 2 : else
2398 [ + ]: 2 : if(typeof dayInfo === 'number'){
2399 : 1 : let tmp = this.#weatherData.days[dayInfo]?.solarenergy;
2400 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2401 [ + ]: 1 : }
2402 : 1 : else{
2403 : 1 : throw new TypeError(`Weather.getSolarenergyOnDay: Invalid input day value '${dayInfo}'.`);
2404 : 1 : }
2405 : 4 : }
2406 [ + ]: 4 : catch(error){
2407 : 1 : return null;
2408 : 1 : }
2409 : 4 : }
2410 : 83 :
2411 : 83 : /**
2412 : 83 : * Core Weather Elements
2413 : 83 : *
2414 : 83 : * @method setSolarenergyOnDay
2415 : 83 : * @instance
2416 : 83 : * @memberof module:weather.Weather
2417 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2418 : 83 : * @param {number} value - The new solar energy level to set.
2419 : 83 : * @desc Sets the solar energy level for a specific day identified by date or index.
2420 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2421 : 83 : */
2422 [ + ]: 83 : setSolarenergyOnDay(dayInfo, value){
2423 : 3 : try{
2424 [ + ]: 3 : if(typeof dayInfo === 'string'){
2425 : 1 : for (let day of this.#weatherData.days){
2426 : 1 : if(day.datetime === dayInfo){
2427 : 1 : day.solarenergy = value;
2428 : 1 : break;
2429 : 1 : }
2430 : 1 : }
2431 [ + ]: 1 : }
2432 : 2 : else
2433 [ + ]: 2 : if(typeof dayInfo === 'number'){
2434 : 1 : let day = this.#weatherData.days[dayInfo];
2435 : 1 : if(day) day.solarenergy = value;
2436 : 1 : }
2437 : 1 : else{
2438 : 1 : throw new TypeError(`Weather.setSolarenergyOnDay: Invalid input day value '${dayInfo}'.`);
2439 : 1 : }
2440 : 3 : }
2441 [ + ]: 3 : catch(error){
2442 : 1 : throw error;
2443 : 1 : }
2444 : 3 : }
2445 : 83 :
2446 : 83 : /**
2447 : 83 : * Core Weather Elements
2448 : 83 : *
2449 : 83 : * @method getUvindexOnDay
2450 : 83 : * @instance
2451 : 83 : * @memberof module:weather.Weather
2452 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2453 : 83 : * @returns {number|null} The UV index for the specified day, or null if not available or error.
2454 : 83 : * @desc Retrieves the UV index for a specific day identified by date or index.
2455 : 83 : */
2456 [ + ]: 83 : getUvindexOnDay(dayInfo){
2457 : 4 : try{
2458 [ + ]: 4 : if(typeof dayInfo === 'string'){
2459 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.uvindex;
2460 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2461 [ + ]: 2 : }
2462 : 2 : else
2463 [ + ]: 2 : if(typeof dayInfo === 'number'){
2464 : 1 : let tmp = this.#weatherData.days[dayInfo]?.uvindex;
2465 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2466 [ + ]: 1 : }
2467 : 1 : else{
2468 : 1 : throw new TypeError(`Weather.getUvindexOnDay: Invalid input day value '${dayInfo}'.`);
2469 : 1 : }
2470 : 4 : }
2471 [ + ]: 4 : catch(error){
2472 : 1 : return null;
2473 : 1 : }
2474 : 4 : }
2475 : 83 :
2476 : 83 : /**
2477 : 83 : * Core Weather Elements
2478 : 83 : *
2479 : 83 : * @method setUvindexOnDay
2480 : 83 : * @instance
2481 : 83 : * @memberof module:weather.Weather
2482 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2483 : 83 : * @param {number} value - The new UV index value to set.
2484 : 83 : * @desc Sets the UV index for a specific day identified by date or index.
2485 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2486 : 83 : */
2487 [ + ]: 83 : setUvindexOnDay(dayInfo, value){
2488 : 3 : try{
2489 [ + ]: 3 : if(typeof dayInfo === 'string'){
2490 : 1 : for (let day of this.#weatherData.days){
2491 : 1 : if(day.datetime === dayInfo){
2492 : 1 : day.uvindex = value;
2493 : 1 : break;
2494 : 1 : }
2495 : 1 : }
2496 [ + ]: 1 : }
2497 : 2 : else
2498 [ + ]: 2 : if(typeof dayInfo === 'number'){
2499 : 1 : let day = this.#weatherData.days[dayInfo];
2500 : 1 : if(day) day.uvindex = value;
2501 : 1 : }
2502 : 1 : else{
2503 : 1 : throw new TypeError(`Weather.setUvindexOnDay: Invalid input day value '${dayInfo}'.`);
2504 : 1 : }
2505 : 3 : }
2506 [ + ]: 3 : catch(error){
2507 : 1 : throw error;
2508 : 1 : }
2509 : 3 : }
2510 : 83 :
2511 : 83 : /**
2512 : 83 : * Core Weather Elements
2513 : 83 : *
2514 : 83 : * @method getSevereriskOnDay
2515 : 83 : * @instance
2516 : 83 : * @memberof module:weather.Weather
2517 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2518 : 83 : * @returns {number|null} The severe weather risk level for the specified day, or null if not available or error.
2519 : 83 : * @desc Retrieves the severe weather risk level for a specific day identified by date or index.
2520 : 83 : */
2521 [ + ]: 83 : getSevereriskOnDay(dayInfo){
2522 : 4 : try{
2523 [ + ]: 4 : if(typeof dayInfo === 'string'){
2524 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.severerisk;
2525 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2526 [ + ]: 2 : }
2527 : 2 : else
2528 [ + ]: 2 : if(typeof dayInfo === 'number'){
2529 : 1 : let tmp = this.#weatherData.days[dayInfo]?.severerisk;
2530 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2531 [ + ]: 1 : }
2532 : 1 : else{
2533 : 1 : throw new TypeError(`Weather.getSevereriskOnDay: Invalid input day value '${dayInfo}'.`);
2534 : 1 : }
2535 : 4 : }
2536 [ + ]: 4 : catch(error){
2537 : 1 : return null;
2538 : 1 : }
2539 : 4 : }
2540 : 83 :
2541 : 83 : /**
2542 : 83 : * Core Weather Elements
2543 : 83 : *
2544 : 83 : * @method setSevereriskOnDay
2545 : 83 : * @instance
2546 : 83 : * @memberof module:weather.Weather
2547 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2548 : 83 : * @param {number} value - The new severe weather risk level to set.
2549 : 83 : * @desc Sets the severe weather risk level for a specific day identified by date or index.
2550 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2551 : 83 : */
2552 [ + ]: 83 : setSevereriskOnDay(dayInfo, value){
2553 : 3 : try{
2554 [ + ]: 3 : if(typeof dayInfo === 'string'){
2555 : 1 : for (let day of this.#weatherData.days){
2556 : 1 : if(day.datetime === dayInfo){
2557 : 1 : day.severerisk = value;
2558 : 1 : break;
2559 : 1 : }
2560 : 1 : }
2561 [ + ]: 1 : }
2562 : 2 : else
2563 [ + ]: 2 : if(typeof dayInfo === 'number'){
2564 : 1 : let day = this.#weatherData.days[dayInfo];
2565 : 1 : if(day) day.severerisk = value;
2566 : 1 : }
2567 : 1 : else{
2568 : 1 : throw new TypeError(`Weather.setSevereriskOnDay: Invalid input day value '${dayInfo}'.`);
2569 : 1 : }
2570 : 3 : }
2571 [ + ]: 3 : catch(error){
2572 : 1 : throw error;
2573 : 1 : }
2574 : 3 : }
2575 : 83 :
2576 : 83 : /**
2577 : 83 : * Core Weather Elements
2578 : 83 : *
2579 : 83 : * @method getStationsOnDay
2580 : 83 : * @instance
2581 : 83 : * @memberof module:weather.Weather
2582 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2583 : 83 : * @returns {Array|null} The list of weather stations active on the specified day, or null if not available or error.
2584 : 83 : * @desc Retrieves the weather stations data for a specific day identified by date or index.
2585 : 83 : */
2586 [ + ]: 83 : getStationsOnDay(dayInfo){
2587 : 4 : try{
2588 [ + ]: 4 : if(typeof dayInfo === 'string'){
2589 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.stations || null;
2590 [ + ]: 2 : }
2591 : 2 : else
2592 [ + ]: 2 : if(typeof dayInfo === 'number'){
2593 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.stations || null;
2594 [ + ]: 1 : }
2595 : 1 : else {
2596 : 1 : throw new TypeError(`Weather.getStationsOnDay: Invalid input day value '${dayInfo}'.`);
2597 : 1 : }
2598 : 4 : }
2599 [ + ]: 4 : catch(error){
2600 : 1 : return null;
2601 : 1 : }
2602 : 4 : }
2603 : 83 :
2604 : 83 : /**
2605 : 83 : * Core Weather Elements
2606 : 83 : *
2607 : 83 : * @method setStationsOnDay
2608 : 83 : * @instance
2609 : 83 : * @memberof module:weather.Weather
2610 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2611 : 83 : * @param {Array} value - The new list of weather stations to set.
2612 : 83 : * @desc Sets the weather stations data for a specific day identified by date or index.
2613 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2614 : 83 : */
2615 [ + ]: 83 : setStationsOnDay(dayInfo, value){
2616 : 3 : try{
2617 [ + ]: 3 : if(typeof dayInfo === 'string'){
2618 : 1 : for(let day of this.#weatherData.days){
2619 : 1 : if(day.datetime === dayInfo){
2620 : 1 : day.stations = value;
2621 : 1 : break;
2622 : 1 : }
2623 : 1 : }
2624 [ + ]: 1 : }
2625 : 2 : else
2626 [ + ]: 2 : if(typeof dayInfo === 'number'){
2627 : 1 : let day = this.#weatherData.days[dayInfo];
2628 : 1 : if(day) day.stations = value;
2629 : 1 : }
2630 : 1 : else{
2631 : 1 : throw new TypeError(`Weather.setStationsOnDay: Invalid input day value '${dayInfo}'.`);
2632 : 1 : }
2633 : 3 : }
2634 [ + ]: 3 : catch(error){
2635 : 1 : throw error;
2636 : 1 : }
2637 : 3 : }
2638 : 83 :
2639 : 83 : /**
2640 : 83 : * Astronomy Elements
2641 : 83 : *
2642 : 83 : * @method getSunriseOnDay
2643 : 83 : * @instance
2644 : 83 : * @memberof module:weather.Weather
2645 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2646 : 83 : * @returns {string|null} The sunrise time for the specified day, or null if not available or error.
2647 : 83 : * @desc Retrieves the sunrise time for a specific day identified by date or index.
2648 : 83 : */
2649 [ + ]: 83 : getSunriseOnDay(dayInfo){
2650 : 4 : try{
2651 [ + ]: 4 : if(typeof dayInfo === 'string'){
2652 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.sunrise || null;
2653 [ + ]: 2 : }
2654 : 2 : else
2655 [ + ]: 2 : if(typeof dayInfo === 'number'){
2656 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.sunrise || null;
2657 [ + ]: 1 : }
2658 : 1 : else{
2659 : 1 : throw new TypeError(`Weather.getSunriseOnDay: Invalid input day value '${dayInfo}'.`);
2660 : 1 : }
2661 : 4 : }
2662 [ + ]: 4 : catch(error){
2663 : 1 : return null;
2664 : 1 : }
2665 : 4 : }
2666 : 83 :
2667 : 83 : /**
2668 : 83 : * Astronomy Elements
2669 : 83 : *
2670 : 83 : * @method setSunriseOnDay
2671 : 83 : * @instance
2672 : 83 : * @memberof module:weather.Weather
2673 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2674 : 83 : * @param {string} value - The new sunrise time value to set.
2675 : 83 : * @desc Sets the sunrise time for a specific day identified by date or index.
2676 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2677 : 83 : */
2678 [ + ]: 83 : setSunriseOnDay(dayInfo, value){
2679 : 3 : try{
2680 [ + ]: 3 : if(typeof dayInfo === 'string'){
2681 : 1 : for(let day of this.#weatherData.days){
2682 : 1 : if(day.datetime === dayInfo){
2683 : 1 : day.sunrise = value;
2684 : 1 : break;
2685 : 1 : }
2686 : 1 : }
2687 [ + ]: 1 : }
2688 : 2 : else
2689 [ + ]: 2 : if(typeof dayInfo === 'number'){
2690 : 1 : let day = this.#weatherData.days[dayInfo];
2691 : 1 : if(day) day.sunrise = value;
2692 : 1 : }
2693 : 1 : else{
2694 : 1 : throw new TypeError(`Weather.setSunriseOnDay: Invalid input day value '${dayInfo}'.`);
2695 : 1 : }
2696 : 3 : }
2697 [ + ]: 3 : catch(error){
2698 : 1 : throw error;
2699 : 1 : }
2700 : 3 : }
2701 : 83 :
2702 : 83 : /**
2703 : 83 : * Astronomy Elements
2704 : 83 : *
2705 : 83 : * @method getSunriseEpochOnDay
2706 : 83 : * @instance
2707 : 83 : * @memberof module:weather.Weather
2708 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2709 : 83 : * @returns {number|null} The sunrise Unix timestamp for the specified day, or null if not available or error.
2710 : 83 : * @desc Retrieves the Unix timestamp for the sunrise time for a specific day.
2711 : 83 : */
2712 [ + ]: 83 : getSunriseEpochOnDay(dayInfo){
2713 : 4 : try{
2714 [ + ]: 4 : if(typeof dayInfo === 'string'){
2715 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.sunriseEpoch;
2716 [ - ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2717 [ + ]: 2 : }
2718 : 2 : else
2719 [ + ]: 2 : if(typeof dayInfo === 'number'){
2720 : 1 : let tmp = this.#weatherData.days[dayInfo]?.sunriseEpoch;
2721 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2722 [ + ]: 1 : }
2723 : 1 : else{
2724 : 1 : throw new TypeError(`Weather.getSunriseEpochOnDay: Invalid input day value '${dayInfo}'.`);
2725 : 1 : }
2726 : 4 : }
2727 [ + ]: 4 : catch(error){
2728 : 1 : return null;
2729 : 1 : }
2730 : 4 : }
2731 : 83 :
2732 : 83 : /**
2733 : 83 : * Astronomy Elements
2734 : 83 : *
2735 : 83 : * @method setSunriseEpochOnDay
2736 : 83 : * @instance
2737 : 83 : * @memberof module:weather.Weather
2738 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2739 : 83 : * @param {number} value - The new sunrise Unix timestamp value to set.
2740 : 83 : * @desc Sets the Unix timestamp for the sunrise time for a specific day.
2741 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2742 : 83 : */
2743 [ + ]: 83 : setSunriseEpochOnDay(dayInfo, value){
2744 : 3 : try{
2745 [ + ]: 3 : if(typeof dayInfo === 'string'){
2746 : 1 : for(let day of this.#weatherData.days){
2747 : 1 : if(day.datetime === dayInfo){
2748 : 1 : day.sunriseEpoch = value;
2749 : 1 : break;
2750 : 1 : }
2751 : 1 : }
2752 [ + ]: 1 : }
2753 : 2 : else
2754 [ + ]: 2 : if(typeof dayInfo === 'number'){
2755 : 1 : let day = this.#weatherData.days[dayInfo];
2756 : 1 : if(day) day.sunriseEpoch = value;
2757 : 1 : }
2758 : 1 : else{
2759 : 1 : throw new TypeError(`Weather.setSunriseEpochOnDay: Invalid input day value '${dayInfo}'.`);
2760 : 1 : }
2761 : 3 : }
2762 [ + ]: 3 : catch(error){
2763 : 1 : throw error;
2764 : 1 : }
2765 : 3 : }
2766 : 83 :
2767 : 83 : /**
2768 : 83 : * Astronomy Elements
2769 : 83 : *
2770 : 83 : * @method getSunsetOnDay
2771 : 83 : * @instance
2772 : 83 : * @memberof module:weather.Weather
2773 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2774 : 83 : * @returns {string|null} The sunset time for the specified day, or null if not available or error.
2775 : 83 : * @desc Retrieves the sunset time for a specific day identified by date or index.
2776 : 83 : */
2777 [ + ]: 83 : getSunsetOnDay(dayInfo){
2778 : 4 : try{
2779 [ + ]: 4 : if(typeof dayInfo === 'string'){
2780 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.sunset || null;
2781 [ + ]: 2 : }
2782 : 2 : else
2783 [ + ]: 2 : if(typeof dayInfo === 'number'){
2784 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.sunset || null;
2785 [ + ]: 1 : }
2786 : 1 : else{
2787 : 1 : throw new TypeError(`Weather.getSunsetOnDay: Invalid input day value '${dayInfo}'.`);
2788 : 1 : }
2789 : 4 : }
2790 [ + ]: 4 : catch(error){
2791 : 1 : return null;
2792 : 1 : }
2793 : 4 : }
2794 : 83 :
2795 : 83 : /**
2796 : 83 : * Astronomy Elements
2797 : 83 : *
2798 : 83 : * @method setSunsetOnDay
2799 : 83 : * @instance
2800 : 83 : * @memberof module:weather.Weather
2801 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2802 : 83 : * @param {string} value - The new sunset time value to set.
2803 : 83 : * @desc Sets the sunset time for a specific day identified by date or index.
2804 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2805 : 83 : */
2806 [ + ]: 83 : setSunsetOnDay(dayInfo, value){
2807 : 3 : try{
2808 [ + ]: 3 : if(typeof dayInfo === 'string'){
2809 : 1 : for(let day of this.#weatherData.days){
2810 : 1 : if(day.datetime === dayInfo){
2811 : 1 : day.sunset = value;
2812 : 1 : break;
2813 : 1 : }
2814 : 1 : }
2815 [ + ]: 1 : }
2816 : 2 : else
2817 [ + ]: 2 : if(typeof dayInfo === 'number'){
2818 : 1 : let day = this.#weatherData.days[dayInfo];
2819 : 1 : if(day) day.sunset = value;
2820 : 1 : }
2821 : 1 : else{
2822 : 1 : throw new TypeError(`Weather.setSunsetOnDay: Invalid input day value '${dayInfo}'.`);
2823 : 1 : }
2824 : 3 : }
2825 [ + ]: 3 : catch(error){
2826 : 1 : throw error;
2827 : 1 : }
2828 : 3 : }
2829 : 83 :
2830 : 83 : /**
2831 : 83 : * Astronomy Elements
2832 : 83 : *
2833 : 83 : * @method getSunsetEpochOnDay
2834 : 83 : * @instance
2835 : 83 : * @memberof module:weather.Weather
2836 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2837 : 83 : * @returns {number|null} The sunset Unix timestamp for the specified day, or null if not available or error.
2838 : 83 : * @desc Retrieves the Unix timestamp for the sunset time for a specific day.
2839 : 83 : */
2840 [ + ]: 83 : getSunsetEpochOnDay(dayInfo){
2841 : 4 : try{
2842 [ + ]: 4 : if(typeof dayInfo === 'string'){
2843 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.sunsetEpoch;
2844 [ - ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2845 [ + ]: 2 : }
2846 : 2 : else
2847 [ + ]: 2 : if(typeof dayInfo === 'number'){
2848 : 1 : let tmp = this.#weatherData.days[dayInfo]?.sunsetEpoch;
2849 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2850 [ + ]: 1 : }
2851 : 1 : else{
2852 : 1 : throw new TypeError(`Weather.getSunsetEpochOnDay: Invalid input day value '${dayInfo}'.`);
2853 : 1 : }
2854 : 4 : }
2855 [ + ]: 4 : catch(error){
2856 : 1 : return null;
2857 : 1 : }
2858 : 4 : }
2859 : 83 :
2860 : 83 : /**
2861 : 83 : * Astronomy Elements
2862 : 83 : *
2863 : 83 : * @method setSunsetEpochOnDay
2864 : 83 : * @instance
2865 : 83 : * @memberof module:weather.Weather
2866 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2867 : 83 : * @param {number} value - The new sunset Unix timestamp value to set.
2868 : 83 : * @desc Sets the Unix timestamp for the sunset time for a specific day.
2869 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2870 : 83 : */
2871 [ + ]: 83 : setSunsetEpochOnDay(dayInfo, value){
2872 : 3 : try{
2873 [ + ]: 3 : if(typeof dayInfo === 'string'){
2874 : 1 : for(let day of this.#weatherData.days){
2875 : 1 : if(day.datetime === dayInfo){
2876 : 1 : day.sunsetEpoch = value;
2877 : 1 : break;
2878 : 1 : }
2879 : 1 : }
2880 [ + ]: 1 : }
2881 : 2 : else
2882 [ + ]: 2 : if(typeof dayInfo === 'number'){
2883 : 1 : let day = this.#weatherData.days[dayInfo];
2884 : 1 : if(day) day.sunsetEpoch = value;
2885 : 1 : }
2886 : 1 : else{
2887 : 1 : throw new TypeError(`Weather.setSunsetEpochOnDay: Invalid input day value '${dayInfo}'.`);
2888 : 1 : }
2889 : 3 : }
2890 [ + ]: 3 : catch(error){
2891 : 1 : throw error;
2892 : 1 : }
2893 : 3 : }
2894 : 83 :
2895 : 83 : /**
2896 : 83 : * Astronomy Elements
2897 : 83 : *
2898 : 83 : * @method getMoonphaseOnDay
2899 : 83 : * @instance
2900 : 83 : * @memberof module:weather.Weather
2901 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2902 : 83 : * @returns {number|null} The moon phase for the specified day, or null if not available or error.
2903 : 83 : * @desc Retrieves the moon phase for a specific day identified by date or index.
2904 : 83 : */
2905 [ + ]: 83 : getMoonphaseOnDay(dayInfo){
2906 : 4 : try{
2907 [ + ]: 4 : if(typeof dayInfo === 'string'){
2908 [ + ][ + ]: 2 : let tmp = this.#weatherData.days.find(day => day.datetime === dayInfo)?.moonphase;
2909 [ + ][ + ]: 2 : return tmp === 0 ? 0 : (tmp || null);
2910 [ + ]: 2 : }
2911 : 2 : else
2912 [ + ]: 2 : if(typeof dayInfo === 'number'){
2913 : 1 : let tmp = this.#weatherData.days[dayInfo]?.moonphase;
2914 [ - ][ - ]: 1 : return tmp === 0 ? 0 : (tmp || null);
2915 [ + ]: 1 : }
2916 : 1 : else{
2917 : 1 : throw new TypeError(`Weather.getMoonphaseOnDay: Invalid input day value '${dayInfo}'.`);
2918 : 1 : }
2919 : 4 : }
2920 [ + ]: 4 : catch(error){
2921 : 1 : return null;
2922 : 1 : }
2923 : 4 : }
2924 : 83 :
2925 : 83 : /**
2926 : 83 : * Astronomy Elements
2927 : 83 : *
2928 : 83 : * @method setMoonphaseOnDay
2929 : 83 : * @instance
2930 : 83 : * @memberof module:weather.Weather
2931 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2932 : 83 : * @param {number} value - The new moon phase value to set.
2933 : 83 : * @desc Sets the moon phase for a specific day identified by date or index.
2934 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2935 : 83 : */
2936 [ + ]: 83 : setMoonphaseOnDay(dayInfo, value){
2937 : 3 : try{
2938 [ + ]: 3 : if(typeof dayInfo === 'string'){
2939 : 1 : for(let day of this.#weatherData.days){
2940 : 1 : if(day.datetime === dayInfo){
2941 : 1 : day.moonphase = value;
2942 : 1 : break;
2943 : 1 : }
2944 : 1 : }
2945 [ + ]: 1 : }
2946 : 2 : else
2947 [ + ]: 2 : if(typeof dayInfo === 'number'){
2948 : 1 : let day = this.#weatherData.days[dayInfo];
2949 : 1 : if(day) day.moonphase = value;
2950 : 1 : }
2951 : 1 : else{
2952 : 1 : throw new TypeError(`Weather.setMoonphaseOnDay: Invalid input day value '${dayInfo}'.`);
2953 : 1 : }
2954 : 3 : }
2955 [ + ]: 3 : catch(error){
2956 : 1 : throw error;
2957 : 1 : }
2958 : 3 : }
2959 : 83 :
2960 : 83 : /**
2961 : 83 : * Description Elements
2962 : 83 : *
2963 : 83 : * @method getConditionsOnDay
2964 : 83 : * @instance
2965 : 83 : * @memberof module:weather.Weather
2966 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2967 : 83 : * @returns {string|null} The weather conditions for the specified day, or null if not available or error.
2968 : 83 : * @desc Retrieves the weather conditions for a specific day identified by date or index.
2969 : 83 : */
2970 [ + ]: 83 : getConditionsOnDay(dayInfo){
2971 : 4 : try{
2972 [ + ]: 4 : if(typeof dayInfo === 'string'){
2973 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.conditions || null;
2974 [ + ]: 2 : }
2975 : 2 : else
2976 [ + ]: 2 : if(typeof dayInfo === 'number'){
2977 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.conditions || null;
2978 [ + ]: 1 : }
2979 : 1 : else{
2980 : 1 : throw new TypeError(`Weather.getConditionsOnDay: Invalid input day value '${dayInfo}'.`);
2981 : 1 : }
2982 : 4 : }
2983 [ + ]: 4 : catch(error){
2984 : 1 : return null;
2985 : 1 : }
2986 : 4 : }
2987 : 83 :
2988 : 83 : /**
2989 : 83 : * Description Elements
2990 : 83 : *
2991 : 83 : * @method setConditionsOnDay
2992 : 83 : * @instance
2993 : 83 : * @memberof module:weather.Weather
2994 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
2995 : 83 : * @param {string} value - The new conditions value to set.
2996 : 83 : * @desc Sets the weather conditions for a specific day identified by date or index.
2997 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
2998 : 83 : */
2999 [ + ]: 83 : setConditionsOnDay(dayInfo, value){
3000 : 3 : try{
3001 [ + ]: 3 : if(typeof dayInfo === 'string'){
3002 : 1 : for(let day of this.#weatherData.days){
3003 : 1 : if(day.datetime === dayInfo){
3004 : 1 : day.conditions = value;
3005 : 1 : break;
3006 : 1 : }
3007 : 1 : }
3008 [ + ]: 1 : }
3009 : 2 : else
3010 [ + ]: 2 : if(typeof dayInfo === 'number'){
3011 : 1 : let day = this.#weatherData.days[dayInfo];
3012 : 1 : if(day) day.conditions = value;
3013 : 1 : }
3014 : 1 : else{
3015 : 1 : throw new TypeError(`Weather.setConditionsOnDay: Invalid input day value '${dayInfo}'.`);
3016 : 1 : }
3017 : 3 : }
3018 [ + ]: 3 : catch(error){
3019 : 1 : throw error;
3020 : 1 : }
3021 : 3 : }
3022 : 83 :
3023 : 83 : /**
3024 : 83 : * Description Elements
3025 : 83 : *
3026 : 83 : * @method getDescriptionOnDay
3027 : 83 : * @instance
3028 : 83 : * @memberof module:weather.Weather
3029 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
3030 : 83 : * @returns {string|null} The weather description for the specified day, or null if not available or error.
3031 : 83 : * @desc Retrieves the weather description for a specific day identified by date or index.
3032 : 83 : */
3033 [ + ]: 83 : getDescriptionOnDay(dayInfo){
3034 : 4 : try{
3035 [ + ]: 4 : if(typeof dayInfo === 'string'){
3036 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.description || null;
3037 [ + ]: 2 : }
3038 : 2 : else
3039 [ + ]: 2 : if(typeof dayInfo === 'number'){
3040 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.description || null;
3041 [ + ]: 1 : }
3042 : 1 : else {
3043 : 1 : throw new TypeError(`Weather.getDescriptionOnDay: Invalid input day value '${dayInfo}'.`);
3044 : 1 : }
3045 : 4 : }
3046 [ + ]: 4 : catch(error){
3047 : 1 : return null;
3048 : 1 : }
3049 : 4 : }
3050 : 83 :
3051 : 83 : /**
3052 : 83 : * Description Elements
3053 : 83 : *
3054 : 83 : * @method setDescriptionOnDay
3055 : 83 : * @instance
3056 : 83 : * @memberof module:weather.Weather
3057 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
3058 : 83 : * @param {string} value - The new description to set.
3059 : 83 : * @desc Sets the weather description for a specific day identified by date or index.
3060 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
3061 : 83 : */
3062 [ + ]: 83 : setDescriptionOnDay(dayInfo, value){
3063 : 3 : try{
3064 [ + ]: 3 : if(typeof dayInfo === 'string'){
3065 : 1 : for(let day of this.#weatherData.days){
3066 : 1 : if(day.datetime === dayInfo){
3067 : 1 : day.description = value;
3068 : 1 : break;
3069 : 1 : }
3070 : 1 : }
3071 [ + ]: 1 : }
3072 : 2 : else
3073 [ + ]: 2 : if(typeof dayInfo === 'number'){
3074 : 1 : let day = this.#weatherData.days[dayInfo];
3075 : 1 : if(day) day.description = value;
3076 : 1 : }
3077 : 1 : else{
3078 : 1 : throw new TypeError(`Weather.setDescriptionOnDay: Invalid input day value '${dayInfo}'.`);
3079 : 1 : }
3080 : 3 : }
3081 [ + ]: 3 : catch(error){
3082 : 1 : throw error;
3083 : 1 : }
3084 : 3 : }
3085 : 83 :
3086 : 83 : /**
3087 : 83 : * Description Elements
3088 : 83 : *
3089 : 83 : * @method getIconOnDay
3090 : 83 : * @instance
3091 : 83 : * @memberof module:weather.Weather
3092 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
3093 : 83 : * @returns {string|null} The weather icon for the specified day, or null if not available or error.
3094 : 83 : * @desc Retrieves the weather icon for a specific day identified by date or index.
3095 : 83 : */
3096 [ + ]: 83 : getIconOnDay(dayInfo){
3097 : 4 : try{
3098 [ + ]: 4 : if(typeof dayInfo === 'string'){
3099 [ + ][ + ][ + ]: 2 : return this.#weatherData.days.find(day => day.datetime === dayInfo)?.icon || null;
3100 [ + ]: 2 : }
3101 : 2 : else
3102 [ + ]: 2 : if(typeof dayInfo === 'number'){
3103 [ - ]: 1 : return this.#weatherData.days[dayInfo]?.icon || null;
3104 [ + ]: 1 : }
3105 : 1 : else{
3106 : 1 : throw new TypeError(`Weather.getIconOnDay: Invalid input day value '${dayInfo}'.`);
3107 : 1 : }
3108 : 4 : }
3109 [ + ]: 4 : catch(error){
3110 : 1 : return null;
3111 : 1 : }
3112 : 4 : }
3113 : 83 :
3114 : 83 : /**
3115 : 83 : * Description Elements
3116 : 83 : *
3117 : 83 : * @method setIconOnDay
3118 : 83 : * @instance
3119 : 83 : * @memberof module:weather.Weather
3120 : 83 : * @param {string|number} dayInfo - The day's date as a string ('YYYY-MM-DD') or index as an integer.
3121 : 83 : * @param {string} value - The new icon to set.
3122 : 83 : * @desc Sets the weather icon for a specific day identified by date or index.
3123 : 83 : * @throws {TypeError} If the dayInfo is neither a string nor a number.
3124 : 83 : */
3125 [ + ]: 83 : setIconOnDay(dayInfo, value){
3126 : 3 : try{
3127 [ + ]: 3 : if(typeof dayInfo === 'string'){
3128 : 1 : for(let day of this.#weatherData.days){
3129 : 1 : if(day.datetime === dayInfo){
3130 : 1 : day.icon = value;
3131 : 1 : break;
3132 : 1 : }
3133 : 1 : }
3134 [ + ]: 1 : }
3135 : 2 : else
3136 [ + ]: 2 : if(typeof dayInfo === 'number'){
3137 : 1 : let day = this.#weatherData.days[dayInfo];
3138 : 1 : if(day) day.icon = value;
3139 : 1 : }
3140 : 1 : else{
3141 : 1 : throw new TypeError(`Weather.setIconOnDay: Invalid input day value '${dayInfo}'.`);
3142 : 1 : }
3143 : 3 : }
3144 [ + ]: 3 : catch(error){
3145 : 1 : throw error;
3146 : 1 : }
3147 : 3 : }
3148 : 83 :
3149 : 83 : /**
3150 : 83 : * Core Weather Elements at datetime
3151 : 83 : *
3152 : 83 : * @method getTempAtDatetime
3153 : 83 : * @instance
3154 : 83 : * @memberof module:weather.Weather
3155 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3156 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3157 : 83 : * @returns {number|null} The temperature at the specified datetime, or null if not available or error.
3158 : 83 : * @desc Retrieves the temperature for a specific datetime within the weather data.
3159 : 83 : */
3160 [ + ]: 83 : getTempAtDatetime(dayInfo, timeInfo){
3161 : 6 : try{
3162 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3163 : 6 :
3164 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3165 : 4 :
3166 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3167 [ + ]: 6 : return hourItem && hourItem.temp;
3168 : 6 : }
3169 [ + ]: 6 : catch(error){
3170 : 2 : return null;
3171 : 2 : }
3172 : 6 : }
3173 : 83 :
3174 : 83 : /**
3175 : 83 : * Core Weather Elements at datetime
3176 : 83 : *
3177 : 83 : * @method getTempAtDatetime
3178 : 83 : * @instance
3179 : 83 : * @memberof module:weather.Weather
3180 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3181 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3182 : 83 : * @param {number} value - The temperature value to be set.
3183 : 83 : * @desc Sets the temperature for a specific datetime within the weather data.
3184 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3185 : 83 : */
3186 [ + ]: 83 : setTempAtDatetime(dayInfo, timeInfo, value){
3187 : 4 : try{
3188 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3189 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).temp = value);
3190 : 4 : }
3191 [ + ]: 4 : catch(error){
3192 : 2 : throw error;
3193 : 2 : }
3194 : 4 : }
3195 : 83 :
3196 : 83 : /**
3197 : 83 : * Core Weather Elements at datetime
3198 : 83 : *
3199 : 83 : * @method getFeelsLikeAtDatetime
3200 : 83 : * @instance
3201 : 83 : * @memberof module:weather.Weather
3202 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3203 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3204 : 83 : * @returns {number|null} The 'feels like' temperature at the specified datetime, or null if not available or error.
3205 : 83 : * @desc Retrieves the 'feels like' temperature for a specific datetime within the weather data.
3206 : 83 : */
3207 [ + ]: 83 : getFeelsLikeAtDatetime(dayInfo, timeInfo){
3208 : 6 : try{
3209 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3210 : 6 :
3211 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3212 : 4 :
3213 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3214 [ + ]: 6 : return hourItem && hourItem.feelslike;
3215 : 6 : }
3216 [ + ]: 6 : catch(error){
3217 : 2 : return null;
3218 : 2 : }
3219 : 6 : }
3220 : 83 :
3221 : 83 : /**
3222 : 83 : * Core Weather Elements at datetime
3223 : 83 : *
3224 : 83 : * @method setFeelsLikeAtDatetime
3225 : 83 : * @instance
3226 : 83 : * @memberof module:weather.Weather
3227 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3228 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3229 : 83 : * @param {number} value - The 'feels like' temperature value to be set.
3230 : 83 : * @desc Sets the 'feels like' temperature for a specific datetime within the weather data.
3231 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3232 : 83 : */
3233 [ + ]: 83 : setFeelsLikeAtDatetime(dayInfo, timeInfo, value){
3234 : 4 : try{
3235 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3236 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).feelslike = value);
3237 : 4 : }
3238 [ + ]: 4 : catch(error){
3239 : 2 : throw error;
3240 : 2 : }
3241 : 4 : }
3242 : 83 :
3243 : 83 : /**
3244 : 83 : * Core Weather Elements at datetime
3245 : 83 : *
3246 : 83 : * @method getDewAtDatetime
3247 : 83 : * @instance
3248 : 83 : * @memberof module:weather.Weather
3249 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3250 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3251 : 83 : * @returns {number|null} The dew point temperature at the specified datetime, or null if not available or error.
3252 : 83 : * @desc Retrieves the dew point temperature for a specific datetime within the weather data.
3253 : 83 : */
3254 [ + ]: 83 : getDewAtDatetime(dayInfo, timeInfo){
3255 : 6 : try{
3256 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3257 : 6 :
3258 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3259 : 4 :
3260 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3261 [ + ]: 6 : return hourItem && hourItem.dew;
3262 : 6 : }
3263 [ + ]: 6 : catch(error){
3264 : 2 : return null;
3265 : 2 : }
3266 : 6 : }
3267 : 83 :
3268 : 83 : /**
3269 : 83 : * Core Weather Elements at datetime
3270 : 83 : *
3271 : 83 : * @method setDewAtDatetime
3272 : 83 : * @instance
3273 : 83 : * @memberof module:weather.Weather
3274 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3275 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3276 : 83 : * @param {number} value - The dew point temperature to be set.
3277 : 83 : * @desc Sets the dew point temperature for a specific datetime within the weather data.
3278 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3279 : 83 : */
3280 [ + ]: 83 : setDewAtDatetime(dayInfo, timeInfo, value){
3281 : 4 : try{
3282 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3283 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).dew = value);
3284 : 4 : }
3285 [ + ]: 4 : catch(error){
3286 : 2 : throw error;
3287 : 2 : }
3288 : 4 : }
3289 : 83 :
3290 : 83 : /**
3291 : 83 : * Core Weather Elements at datetime
3292 : 83 : *
3293 : 83 : * @method getHumidityAtDatetime
3294 : 83 : * @instance
3295 : 83 : * @memberof module:weather.Weather
3296 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3297 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3298 : 83 : * @returns {number|null} The humidity percentage at the specified datetime, or null if not available or error.
3299 : 83 : * @desc Retrieves the humidity for a specific datetime within the weather data.
3300 : 83 : */
3301 [ + ]: 83 : getHumidityAtDatetime(dayInfo, timeInfo){
3302 : 6 : try{
3303 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3304 : 6 :
3305 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3306 : 4 :
3307 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3308 [ + ]: 6 : return hourItem && hourItem.humidity;
3309 : 6 : }
3310 [ + ]: 6 : catch(error){
3311 : 2 : return null;
3312 : 2 : }
3313 : 6 : }
3314 : 83 :
3315 : 83 : /**
3316 : 83 : * Core Weather Elements at datetime
3317 : 83 : *
3318 : 83 : * @method setHumidityAtDatetime
3319 : 83 : * @instance
3320 : 83 : * @memberof module:weather.Weather
3321 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3322 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3323 : 83 : * @param {number} value - The humidity percentage to be set.
3324 : 83 : * @desc Sets the humidity for a specific datetime within the weather data.
3325 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3326 : 83 : */
3327 [ + ]: 83 : setHumidityAtDatetime(dayInfo, timeInfo, value){
3328 : 4 : try{
3329 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3330 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).humidity = value);
3331 : 4 : }
3332 [ + ]: 4 : catch(error){
3333 : 2 : throw error;
3334 : 2 : }
3335 : 4 : }
3336 : 83 :
3337 : 83 : /**
3338 : 83 : * Core Weather Elements at datetime
3339 : 83 : *
3340 : 83 : * @method getPrecipAtDatetime
3341 : 83 : * @instance
3342 : 83 : * @memberof module:weather.Weather
3343 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3344 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3345 : 83 : * @returns {number|null} The precipitation amount at the specified datetime, or null if not available or error.
3346 : 83 : * @desc Retrieves the precipitation amount for a specific datetime within the weather data.
3347 : 83 : */
3348 [ + ]: 83 : getPrecipAtDatetime(dayInfo, timeInfo){
3349 : 6 : try{
3350 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3351 : 6 :
3352 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3353 : 4 :
3354 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3355 [ + ]: 6 : return hourItem && hourItem.precip;
3356 : 6 : }
3357 [ + ]: 6 : catch(error){
3358 : 2 : return null;
3359 : 2 : }
3360 : 6 : }
3361 : 83 :
3362 : 83 : /**
3363 : 83 : * Core Weather Elements at datetime
3364 : 83 : *
3365 : 83 : * @method setPrecipAtDatetime
3366 : 83 : * @instance
3367 : 83 : * @memberof module:weather.Weather
3368 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3369 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3370 : 83 : * @param {number} value - The precipitation amount to be set.
3371 : 83 : * @desc Sets the precipitation amount for a specific datetime within the weather data.
3372 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3373 : 83 : */
3374 [ + ]: 83 : setPrecipAtDatetime(dayInfo, timeInfo, value){
3375 : 4 : try{
3376 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3377 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).precip = value);
3378 : 4 : }
3379 [ + ]: 4 : catch(error){
3380 : 2 : throw error;
3381 : 2 : }
3382 : 4 : }
3383 : 83 :
3384 : 83 : /**
3385 : 83 : * Core Weather Elements at datetime
3386 : 83 : *
3387 : 83 : * @method getPrecipProbAtDatetime
3388 : 83 : * @instance
3389 : 83 : * @memberof module:weather.Weather
3390 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3391 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3392 : 83 : * @returns {number|null} The probability of precipitation at the specified datetime, or null if not available or error.
3393 : 83 : * @desc Retrieves the probability of precipitation for a specific datetime within the weather data.
3394 : 83 : */
3395 [ + ]: 83 : getPrecipProbAtDatetime(dayInfo, timeInfo){
3396 : 6 : try{
3397 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3398 : 6 :
3399 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3400 : 4 :
3401 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3402 [ + ]: 6 : return hourItem && hourItem.precipprob;
3403 : 6 : }
3404 [ + ]: 6 : catch(error){
3405 : 2 : return null;
3406 : 2 : }
3407 : 6 : }
3408 : 83 :
3409 : 83 : /**
3410 : 83 : * Core Weather Elements at datetime
3411 : 83 : *
3412 : 83 : * @method setPrecipProbAtDatetime
3413 : 83 : * @instance
3414 : 83 : * @memberof module:weather.Weather
3415 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3416 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3417 : 83 : * @param {number} value - The probability of precipitation to be set.
3418 : 83 : * @desc Sets the probability of precipitation for a specific datetime within the weather data.
3419 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3420 : 83 : */
3421 [ + ]: 83 : setPrecipProbAtDatetime(dayInfo, timeInfo, value){
3422 : 4 : try{
3423 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3424 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).precipprob = value);
3425 : 4 : }
3426 [ + ]: 4 : catch(error){
3427 : 2 : throw error;
3428 : 2 : }
3429 : 4 : }
3430 : 83 :
3431 : 83 : /**
3432 : 83 : * Core Weather Elements at datetime
3433 : 83 : *
3434 : 83 : * @method getPreciptypeAtDatetime
3435 : 83 : * @instance
3436 : 83 : * @memberof module:weather.Weather
3437 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3438 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3439 : 83 : * @returns {string} The type of precipitation at the specified datetime, or null if not available or error.
3440 : 83 : * @desc Retrieves the type of precipitation for a specific datetime within the weather data.
3441 : 83 : */
3442 [ + ]: 83 : getPreciptypeAtDatetime(dayInfo, timeInfo){
3443 : 6 : try{
3444 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3445 : 6 :
3446 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3447 : 4 :
3448 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3449 [ + ]: 6 : return hourItem && hourItem.preciptype;
3450 : 6 : }
3451 [ + ]: 6 : catch(error){
3452 : 2 : return null;
3453 : 2 : }
3454 : 6 : }
3455 : 83 :
3456 : 83 : /**
3457 : 83 : * Core Weather Elements at datetime
3458 : 83 : *
3459 : 83 : * @method setPreciptypeAtDatetime
3460 : 83 : * @instance
3461 : 83 : * @memberof module:weather.Weather
3462 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3463 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3464 : 83 : * @param {string} value - The type of precipitation to be set.
3465 : 83 : * @desc Sets the type of precipitation for a specific datetime within the weather data.
3466 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3467 : 83 : */
3468 [ + ]: 83 : setPreciptypeAtDatetime(dayInfo, timeInfo, value){
3469 : 4 : try{
3470 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3471 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).preciptype = value);
3472 : 4 : }
3473 [ + ]: 4 : catch(error){
3474 : 2 : throw error;
3475 : 2 : }
3476 : 4 : }
3477 : 83 :
3478 : 83 : /**
3479 : 83 : * Core Weather Elements at datetime
3480 : 83 : *
3481 : 83 : * @method getSnowAtDatetime
3482 : 83 : * @instance
3483 : 83 : * @memberof module:weather.Weather
3484 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3485 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3486 : 83 : * @returns {number|null} The snow amount at the specified datetime, or null if not available or error.
3487 : 83 : * @desc Retrieves the snow amount for a specific datetime within the weather data.
3488 : 83 : */
3489 [ + ]: 83 : getSnowAtDatetime(dayInfo, timeInfo){
3490 : 6 : try{
3491 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3492 : 6 :
3493 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3494 : 4 :
3495 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3496 [ + ]: 6 : return hourItem && hourItem.snow;
3497 : 6 : }
3498 [ + ]: 6 : catch(error){
3499 : 2 : return null;
3500 : 2 : }
3501 : 6 : }
3502 : 83 :
3503 : 83 : /**
3504 : 83 : * Core Weather Elements at datetime
3505 : 83 : *
3506 : 83 : * @method setSnowAtDatetime
3507 : 83 : * @instance
3508 : 83 : * @memberof module:weather.Weather
3509 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3510 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3511 : 83 : * @param {number} value - The snow amount to be set.
3512 : 83 : * @desc Sets the snow amount for a specific datetime within the weather data.
3513 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3514 : 83 : */
3515 [ + ]: 83 : setSnowAtDatetime(dayInfo, timeInfo, value){
3516 : 4 : try{
3517 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3518 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).snow = value);
3519 : 4 : }
3520 [ + ]: 4 : catch(error){
3521 : 2 : throw error;
3522 : 2 : }
3523 : 4 : }
3524 : 83 :
3525 : 83 : /**
3526 : 83 : * Core Weather Elements at datetime
3527 : 83 : *
3528 : 83 : * @method getSnowDepthAtDatetime
3529 : 83 : * @instance
3530 : 83 : * @memberof module:weather.Weather
3531 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3532 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3533 : 83 : * @returns {number|null} The snow depth at the specified datetime, or null if not available or error.
3534 : 83 : * @desc Retrieves the snow depth for a specific datetime within the weather data.
3535 : 83 : */
3536 [ + ]: 83 : getSnowDepthAtDatetime(dayInfo, timeInfo){
3537 : 6 : try{
3538 : 6 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3539 : 6 :
3540 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3541 : 4 :
3542 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3543 [ + ]: 6 : return hourItem && hourItem.snowdepth;
3544 : 6 : }
3545 [ + ]: 6 : catch(error){
3546 : 2 : return null;
3547 : 2 : }
3548 : 6 : }
3549 : 83 :
3550 : 83 : /**
3551 : 83 : * Core Weather Elements at datetime
3552 : 83 : *
3553 : 83 : * @method setSnowDepthAtDatetime
3554 : 83 : * @instance
3555 : 83 : * @memberof module:weather.Weather
3556 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3557 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3558 : 83 : * @param {number} value - The snow depth to be set.
3559 : 83 : * @desc Sets the snow depth for a specific datetime within the weather data.
3560 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3561 : 83 : */
3562 [ + ]: 83 : setSnowDepthAtDatetime(dayInfo, timeInfo, value){
3563 : 4 : try{
3564 : 4 : const dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3565 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).snowdepth = value);
3566 : 4 : }
3567 [ + ]: 4 : catch(error){
3568 : 2 : throw error;
3569 : 2 : }
3570 : 4 : }
3571 : 83 :
3572 : 83 : /**
3573 : 83 : * Core Weather Elements at datetime
3574 : 83 : *
3575 : 83 : * @method getWindgustAtDatetime
3576 : 83 : * @instance
3577 : 83 : * @memberof module:weather.Weather
3578 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3579 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3580 : 83 : * @returns {number|null} The wind gust speed at the specified datetime, or null if not available or error.
3581 : 83 : * @desc Retrieves the wind gust speed for a specific datetime within the weather data.
3582 : 83 : */
3583 [ + ]: 83 : getWindgustAtDatetime(dayInfo, timeInfo){
3584 : 6 : try{
3585 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3586 : 6 :
3587 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3588 : 4 :
3589 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3590 [ + ]: 6 : return hourItem && hourItem.windgust;
3591 : 6 : }
3592 [ + ]: 6 : catch(error){
3593 : 2 : return null;
3594 : 2 : }
3595 : 6 : }
3596 : 83 :
3597 : 83 : /**
3598 : 83 : * Core Weather Elements at datetime
3599 : 83 : *
3600 : 83 : * @method setWindgustAtDatetime
3601 : 83 : * @instance
3602 : 83 : * @memberof module:weather.Weather
3603 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3604 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3605 : 83 : * @param {number} value - The wind gust speed to be set.
3606 : 83 : * @desc Sets the wind gust speed for a specific datetime within the weather data.
3607 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3608 : 83 : */
3609 [ + ]: 83 : setWindgustAtDatetime(dayInfo, timeInfo, value){
3610 : 4 : try{
3611 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3612 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).windgust = value);
3613 : 4 : }
3614 [ + ]: 4 : catch(error){
3615 : 2 : throw error;
3616 : 2 : }
3617 : 4 : }
3618 : 83 :
3619 : 83 : /**
3620 : 83 : * Core Weather Elements at datetime
3621 : 83 : *
3622 : 83 : * @method getWindspeedAtDatetime
3623 : 83 : * @instance
3624 : 83 : * @memberof module:weather.Weather
3625 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3626 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3627 : 83 : * @returns {number|null} The wind speed at the specified datetime, or null if not available or error.
3628 : 83 : * @desc Retrieves the wind speed for a specific datetime within the weather data.
3629 : 83 : */
3630 [ + ]: 83 : getWindspeedAtDatetime(dayInfo, timeInfo){
3631 : 6 : try{
3632 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3633 : 6 :
3634 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3635 : 4 :
3636 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3637 [ + ]: 6 : return hourItem && hourItem.windspeed;
3638 : 6 : }
3639 [ + ]: 6 : catch(error){
3640 : 2 : return null;
3641 : 2 : }
3642 : 6 : }
3643 : 83 :
3644 : 83 : /**
3645 : 83 : * Core Weather Elements at datetime
3646 : 83 : *
3647 : 83 : * @method setWindspeedAtDatetime
3648 : 83 : * @instance
3649 : 83 : * @memberof module:weather.Weather
3650 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3651 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3652 : 83 : * @param {number} value - The wind speed to be set.
3653 : 83 : * @desc Sets the wind speed for a specific datetime within the weather data.
3654 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3655 : 83 : */
3656 [ + ]: 83 : setWindspeedAtDatetime(dayInfo, timeInfo, value){
3657 : 4 : try{
3658 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3659 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).windspeed = value);
3660 : 4 : }
3661 [ + ]: 4 : catch(error){
3662 : 2 : throw error;
3663 : 2 : }
3664 : 4 : }
3665 : 83 :
3666 : 83 : /**
3667 : 83 : * Core Weather Elements at datetime
3668 : 83 : *
3669 : 83 : * @method getWinddirAtDatetime
3670 : 83 : * @instance
3671 : 83 : * @memberof module:weather.Weather
3672 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3673 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3674 : 83 : * @returns {number|null} The wind direction at the specified datetime, or null if not available or error.
3675 : 83 : * @desc Retrieves the wind direction for a specific datetime within the weather data.
3676 : 83 : */
3677 [ + ]: 83 : getWinddirAtDatetime(dayInfo, timeInfo){
3678 : 6 : try{
3679 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3680 : 6 :
3681 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3682 : 4 :
3683 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3684 [ + ]: 6 : return hourItem && hourItem.winddir;
3685 : 6 : }
3686 [ + ]: 6 : catch(error){
3687 : 2 : return null;
3688 : 2 : }
3689 : 6 : }
3690 : 83 :
3691 : 83 : /**
3692 : 83 : * Core Weather Elements at datetime
3693 : 83 : *
3694 : 83 : * @method setWinddirAtDatetime
3695 : 83 : * @instance
3696 : 83 : * @memberof module:weather.Weather
3697 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3698 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3699 : 83 : * @param {number} value - The wind direction to be set.
3700 : 83 : * @desc Sets the wind direction for a specific datetime within the weather data.
3701 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3702 : 83 : */
3703 [ + ]: 83 : setWinddirAtDatetime(dayInfo, timeInfo, value){
3704 : 4 : try{
3705 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3706 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).winddir = value);
3707 : 4 : }
3708 [ + ]: 4 : catch(error){
3709 : 2 : throw error;
3710 : 2 : }
3711 : 4 : }
3712 : 83 :
3713 : 83 : /**
3714 : 83 : * Core Weather Elements at datetime
3715 : 83 : *
3716 : 83 : * @method getPressureAtDatetime
3717 : 83 : * @instance
3718 : 83 : * @memberof module:weather.Weather
3719 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3720 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3721 : 83 : * @returns {number|null} The atmospheric pressure at the specified datetime, or null if not available or error.
3722 : 83 : * @desc Retrieves the atmospheric pressure for a specific datetime within the weather data.
3723 : 83 : */
3724 [ + ]: 83 : getPressureAtDatetime(dayInfo, timeInfo){
3725 : 6 : try{
3726 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3727 : 6 :
3728 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3729 : 4 :
3730 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3731 [ + ]: 6 : return hourItem && hourItem.pressure;
3732 : 6 : }
3733 [ + ]: 6 : catch(error){
3734 : 2 : return null;
3735 : 2 : }
3736 : 6 : }
3737 : 83 :
3738 : 83 : /**
3739 : 83 : * Core Weather Elements at datetime
3740 : 83 : *
3741 : 83 : * @method setPressureAtDatetime
3742 : 83 : * @instance
3743 : 83 : * @memberof module:weather.Weather
3744 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3745 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3746 : 83 : * @param {number} value - The atmospheric pressure to be set.
3747 : 83 : * @desc Sets the atmospheric pressure for a specific datetime within the weather data.
3748 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3749 : 83 : */
3750 [ + ]: 83 : setPressureAtDatetime(dayInfo, timeInfo, value){
3751 : 4 : try{
3752 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3753 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).pressure = value);
3754 : 4 : }
3755 [ + ]: 4 : catch(error){
3756 : 2 : throw error;
3757 : 2 : }
3758 : 4 : }
3759 : 83 :
3760 : 83 : /**
3761 : 83 : * Core Weather Elements at datetime
3762 : 83 : *
3763 : 83 : * @method getCloudcoverAtDatetime
3764 : 83 : * @instance
3765 : 83 : * @memberof module:weather.Weather
3766 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3767 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3768 : 83 : * @returns {number|null} The cloud cover at the specified datetime, or null if not available or error.
3769 : 83 : * @desc Retrieves the cloud cover for a specific datetime within the weather data.
3770 : 83 : */
3771 [ + ]: 83 : getCloudcoverAtDatetime(dayInfo, timeInfo){
3772 : 6 : try{
3773 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3774 : 6 :
3775 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3776 : 4 :
3777 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3778 [ + ]: 6 : return hourItem && hourItem.cloudcover;
3779 : 6 : }
3780 [ + ]: 6 : catch(error){
3781 : 2 : return null;
3782 : 2 : }
3783 : 6 : }
3784 : 83 :
3785 : 83 : /**
3786 : 83 : * Core Weather Elements at datetime
3787 : 83 : *
3788 : 83 : * @method setCloudcoverAtDatetime
3789 : 83 : * @instance
3790 : 83 : * @memberof module:weather.Weather
3791 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3792 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3793 : 83 : * @param {number} value - The cloud cover to be set.
3794 : 83 : * @desc Sets the cloud cover for a specific datetime within the weather data.
3795 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3796 : 83 : */
3797 [ + ]: 83 : setCloudcoverAtDatetime(dayInfo, timeInfo, value){
3798 : 4 : try{
3799 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3800 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).cloudcover = value);
3801 : 4 : }
3802 [ + ]: 4 : catch(error){
3803 : 2 : throw error;
3804 : 2 : }
3805 : 4 : }
3806 : 83 :
3807 : 83 : /**
3808 : 83 : * Core Weather Elements at datetime
3809 : 83 : *
3810 : 83 : * @method getVisibilityAtDatetime
3811 : 83 : * @instance
3812 : 83 : * @memberof module:weather.Weather
3813 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3814 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3815 : 83 : * @returns {number|null} The visibility at the specified datetime, or null if not available or error.
3816 : 83 : * @desc Retrieves the visibility for a specific datetime within the weather data.
3817 : 83 : */
3818 [ + ]: 83 : getVisibilityAtDatetime(dayInfo, timeInfo){
3819 : 6 : try{
3820 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3821 : 6 :
3822 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3823 : 4 :
3824 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3825 [ + ]: 6 : return hourItem && hourItem.visibility;
3826 : 6 : }
3827 [ + ]: 6 : catch(error){
3828 : 2 : return null;
3829 : 2 : }
3830 : 6 : }
3831 : 83 :
3832 : 83 : /**
3833 : 83 : * Core Weather Elements at datetime
3834 : 83 : *
3835 : 83 : * @method setVisibilityAtDatetime
3836 : 83 : * @instance
3837 : 83 : * @memberof module:weather.Weather
3838 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3839 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3840 : 83 : * @param {number} value - The visibility to be set.
3841 : 83 : * @desc Sets the visibility for a specific datetime within the weather data.
3842 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3843 : 83 : */
3844 [ + ]: 83 : setVisibilityAtDatetime(dayInfo, timeInfo, value){
3845 : 4 : try{
3846 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3847 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).visibility = value);
3848 : 4 : }
3849 [ + ]: 4 : catch(error){
3850 : 2 : throw error;
3851 : 2 : }
3852 : 4 : }
3853 : 83 :
3854 : 83 : /**
3855 : 83 : * Core Weather Elements at datetime
3856 : 83 : *
3857 : 83 : * @method getSolarradiationAtDatetime
3858 : 83 : * @instance
3859 : 83 : * @memberof module:weather.Weather
3860 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3861 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3862 : 83 : * @returns {number|null} The solar radiation at the specified datetime, or null if not available or error.
3863 : 83 : * @desc Retrieves the solar radiation for a specific datetime within the weather data.
3864 : 83 : */
3865 [ + ]: 83 : getSolarradiationAtDatetime(dayInfo, timeInfo){
3866 : 6 : try{
3867 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3868 : 6 :
3869 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3870 : 4 :
3871 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3872 [ + ]: 6 : return hourItem && hourItem.solarradiation;
3873 : 6 : }
3874 [ + ]: 6 : catch(error){
3875 : 2 : return null;
3876 : 2 : }
3877 : 6 : }
3878 : 83 :
3879 : 83 : /**
3880 : 83 : * Core Weather Elements at datetime
3881 : 83 : *
3882 : 83 : * @method setSolarradiationAtDatetime
3883 : 83 : * @instance
3884 : 83 : * @memberof module:weather.Weather
3885 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3886 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3887 : 83 : * @param {number} value - The solar radiation to be set.
3888 : 83 : * @desc Sets the solar radiation for a specific datetime within the weather data.
3889 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3890 : 83 : */
3891 [ + ]: 83 : setSolarradiationAtDatetime(dayInfo, timeInfo, value){
3892 : 4 : try{
3893 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3894 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).solarradiation = value);
3895 : 4 : }
3896 [ + ]: 4 : catch(error){
3897 : 2 : throw error;
3898 : 2 : }
3899 : 4 : }
3900 : 83 :
3901 : 83 : /**
3902 : 83 : * Core Weather Elements at datetime
3903 : 83 : *
3904 : 83 : * @method getSolarenergyAtDatetime
3905 : 83 : * @instance
3906 : 83 : * @memberof module:weather.Weather
3907 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3908 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3909 : 83 : * @returns {number|null} The solar energy at the specified datetime, or null if not available or error.
3910 : 83 : * @desc Retrieves the solar energy for a specific datetime within the weather data.
3911 : 83 : */
3912 [ + ]: 83 : getSolarenergyAtDatetime(dayInfo, timeInfo){
3913 : 6 : try{
3914 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3915 : 6 :
3916 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3917 : 4 :
3918 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3919 [ + ]: 6 : return hourItem && hourItem.solarenergy;
3920 : 6 : }
3921 [ + ]: 6 : catch(error){
3922 : 2 : return null;
3923 : 2 : }
3924 : 6 : }
3925 : 83 :
3926 : 83 : /**
3927 : 83 : * Core Weather Elements at datetime
3928 : 83 : *
3929 : 83 : * @method setSolarenergyAtDatetime
3930 : 83 : * @instance
3931 : 83 : * @memberof module:weather.Weather
3932 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3933 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3934 : 83 : * @param {number} value - The solar energy to be set.
3935 : 83 : * @desc Sets the solar energy for a specific datetime within the weather data.
3936 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3937 : 83 : */
3938 [ + ]: 83 : setSolarenergyAtDatetime(dayInfo, timeInfo, value){
3939 : 4 : try{
3940 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3941 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).solarenergy = value);
3942 : 4 : }
3943 [ + ]: 4 : catch(error){
3944 : 2 : throw error;
3945 : 2 : }
3946 : 4 : }
3947 : 83 :
3948 : 83 : /**
3949 : 83 : * Core Weather Elements at datetime
3950 : 83 : *
3951 : 83 : * @method getUvindexAtDatetime
3952 : 83 : * @instance
3953 : 83 : * @memberof module:weather.Weather
3954 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3955 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3956 : 83 : * @returns {number|null} The UV index at the specified datetime, or null if not available or error.
3957 : 83 : * @desc Retrieves the UV index for a specific datetime within the weather data.
3958 : 83 : */
3959 [ + ]: 83 : getUvindexAtDatetime(dayInfo, timeInfo){
3960 : 6 : try{
3961 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3962 : 6 :
3963 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
3964 : 4 :
3965 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
3966 [ + ]: 6 : return hourItem && hourItem.uvindex;
3967 : 6 : }
3968 [ + ]: 6 : catch(error){
3969 : 2 : return null;
3970 : 2 : }
3971 : 6 : }
3972 : 83 :
3973 : 83 : /**
3974 : 83 : * Core Weather Elements at datetime
3975 : 83 : *
3976 : 83 : * @method setUvindexAtDatetime
3977 : 83 : * @instance
3978 : 83 : * @memberof module:weather.Weather
3979 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
3980 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
3981 : 83 : * @param {number} value - The UV index to be set.
3982 : 83 : * @desc Sets the UV index for a specific datetime within the weather data.
3983 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
3984 : 83 : */
3985 [ + ]: 83 : setUvindexAtDatetime(dayInfo, timeInfo, value){
3986 : 4 : try{
3987 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
3988 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).uvindex = value);
3989 : 4 : }
3990 [ + ]: 4 : catch(error){
3991 : 2 : throw error;
3992 : 2 : }
3993 : 4 : }
3994 : 83 :
3995 : 83 : /**
3996 : 83 : * Core Weather Elements at datetime
3997 : 83 : *
3998 : 83 : * @method getSevereriskAtDatetime
3999 : 83 : * @instance
4000 : 83 : * @memberof module:weather.Weather
4001 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4002 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4003 : 83 : * @returns {number|null} The severe risk at the specified datetime, or null if not available or error.
4004 : 83 : * @desc Retrieves the severe risk for a specific datetime within the weather data.
4005 : 83 : */
4006 [ + ]: 83 : getSevereriskAtDatetime(dayInfo, timeInfo){
4007 : 6 : try{
4008 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4009 : 6 :
4010 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
4011 : 4 :
4012 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
4013 [ + ]: 6 : return hourItem && hourItem.severerisk;
4014 : 6 : }
4015 [ + ]: 6 : catch(error){
4016 : 2 : return null;
4017 : 2 : }
4018 : 6 : }
4019 : 83 :
4020 : 83 : /**
4021 : 83 : * Core Weather Elements at datetime
4022 : 83 : *
4023 : 83 : * @method setSevereriskAtDatetime
4024 : 83 : * @instance
4025 : 83 : * @memberof module:weather.Weather
4026 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4027 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4028 : 83 : * @param {number} value - The severe risk to be set.
4029 : 83 : * @desc Sets the severe risk for a specific datetime within the weather data.
4030 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
4031 : 83 : */
4032 [ + ]: 83 : setSevereriskAtDatetime(dayInfo, timeInfo, value){
4033 : 4 : try{
4034 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4035 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).severerisk = value);
4036 : 4 : }
4037 [ + ]: 4 : catch(error){
4038 : 2 : throw error;
4039 : 2 : }
4040 : 4 : }
4041 : 83 :
4042 : 83 : /**
4043 : 83 : * Core Weather Elements at datetime
4044 : 83 : *
4045 : 83 : * @method getStationsAtDatetime
4046 : 83 : * @instance
4047 : 83 : * @memberof module:weather.Weather
4048 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4049 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4050 : 83 : * @returns {string[]|null} The weather stations that were used for creating the observation at the specified datetime, or null if not available or error.
4051 : 83 : * @desc Retrieves the weather stations that were used for creating the observation for a specific datetime within the weather data.
4052 : 83 : */
4053 [ + ]: 83 : getStationsAtDatetime(dayInfo, timeInfo){
4054 : 6 : try{
4055 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4056 : 6 :
4057 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
4058 : 4 :
4059 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
4060 [ + ]: 6 : return hourItem && hourItem.stations;
4061 : 6 : }
4062 [ + ]: 6 : catch(error){
4063 : 2 : return null;
4064 : 2 : }
4065 : 6 : }
4066 : 83 :
4067 : 83 : /**
4068 : 83 : * Core Weather Elements at datetime
4069 : 83 : *
4070 : 83 : * @method setStationsAtDatetime
4071 : 83 : * @instance
4072 : 83 : * @memberof module:weather.Weather
4073 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4074 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4075 : 83 : * @param {string[]} value - The weather stations to be set.
4076 : 83 : * @desc Sets the weather stations that were used for creating the observation for a specific datetime within the weather data.
4077 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
4078 : 83 : */
4079 [ + ]: 83 : setStationsAtDatetime(dayInfo, timeInfo, value){
4080 : 4 : try{
4081 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4082 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).stations = value);
4083 : 4 : }
4084 [ + ]: 4 : catch(error){
4085 : 2 : throw error;
4086 : 2 : }
4087 : 4 : }
4088 : 83 :
4089 : 83 : /**
4090 : 83 : * Core Weather Elements at datetime
4091 : 83 : *
4092 : 83 : * @method getSourceAtDatetime
4093 : 83 : * @instance
4094 : 83 : * @memberof module:weather.Weather
4095 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4096 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4097 : 83 : * @returns {string|null} The type of weather data used for this weather object at the specified datetime, or null if not available or error.
4098 : 83 : * @desc Retrieves the type of weather data used for this weather object for a specific datetime within the weather data.
4099 : 83 : * Values include historical observation (“obs”), forecast (“fcst”), historical forecast (“histfcst”) or statistical forecast (“stats”).
4100 : 83 : * If multiple types are used in the same day, “comb” is used. Today a combination of historical observations and forecast data.
4101 : 83 : */
4102 [ + ]: 83 : getSourceAtDatetime(dayInfo, timeInfo){
4103 : 6 : try{
4104 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4105 : 6 :
4106 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
4107 : 4 :
4108 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
4109 [ + ]: 6 : return hourItem && hourItem.source;
4110 : 6 : }
4111 [ + ]: 6 : catch(error){
4112 : 2 : return null;
4113 : 2 : }
4114 : 6 : }
4115 : 83 :
4116 : 83 : /**
4117 : 83 : * Core Weather Elements at datetime
4118 : 83 : *
4119 : 83 : * @method setSourceAtDatetime
4120 : 83 : * @instance
4121 : 83 : * @memberof module:weather.Weather
4122 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4123 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4124 : 83 : * @param {string} value - The type of weather data to be set.
4125 : 83 : * @desc Sets the type of weather data used for this weather object for a specific datetime within the weather data.
4126 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
4127 : 83 : */
4128 [ + ]: 83 : setSourceAtDatetime(dayInfo, timeInfo, value){
4129 : 4 : try{
4130 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4131 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).source = value);
4132 : 4 : }
4133 [ + ]: 4 : catch(error){
4134 : 2 : throw error;
4135 : 2 : }
4136 : 4 : }
4137 : 83 :
4138 : 83 : /**
4139 : 83 : * Description Elements at datetime
4140 : 83 : *
4141 : 83 : * @method getConditionsAtDatetime
4142 : 83 : * @instance
4143 : 83 : * @memberof module:weather.Weather
4144 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4145 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4146 : 83 : * @returns {string} The conditions at the specified datetime, or null if not available or error.
4147 : 83 : * @desc Retrieves the conditions for a specific datetime within the weather data.
4148 : 83 : */
4149 [ + ]: 83 : getConditionsAtDatetime(dayInfo, timeInfo){
4150 : 6 : try{
4151 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4152 : 6 :
4153 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
4154 : 4 :
4155 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
4156 [ + ]: 6 : return hourItem && hourItem.conditions;
4157 : 6 : }
4158 [ + ]: 6 : catch(error){
4159 : 2 : return null;
4160 : 2 : }
4161 : 6 : }
4162 : 83 :
4163 : 83 : /**
4164 : 83 : * Description Elements at datetime
4165 : 83 : *
4166 : 83 : * @method setConditionsAtDatetime
4167 : 83 : * @instance
4168 : 83 : * @memberof module:weather.Weather
4169 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4170 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4171 : 83 : * @param {string} value - The conditions to be set.
4172 : 83 : * @desc Sets the conditions for a specific datetime within the weather data.
4173 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
4174 : 83 : */
4175 [ + ]: 83 : setConditionsAtDatetime(dayInfo, timeInfo, value){
4176 : 4 : try{
4177 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4178 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).conditions = value);
4179 : 4 : }
4180 [ + ]: 4 : catch(error){
4181 : 2 : throw error;
4182 : 2 : }
4183 : 4 : }
4184 : 83 :
4185 : 83 : /**
4186 : 83 : * Description Elements at datetime
4187 : 83 : *
4188 : 83 : * @method getIconAtDatetime
4189 : 83 : * @instance
4190 : 83 : * @memberof module:weather.Weather
4191 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4192 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4193 : 83 : * @returns {string} The weather icon at the specified datetime, or null if not available or error.
4194 : 83 : * @desc Retrieves the weather icon for a specific datetime within the weather data.
4195 : 83 : */
4196 [ + ]: 83 : getIconAtDatetime(dayInfo, timeInfo){
4197 : 6 : try{
4198 : 6 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4199 : 6 :
4200 [ + ][ + ]: 6 : if(!dayItem) return dayItem;
4201 : 4 :
4202 : 4 : const hourItem = Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo);
4203 [ + ]: 6 : return hourItem && hourItem.icon;
4204 : 6 : }
4205 [ + ]: 6 : catch(error){
4206 : 2 : return null;
4207 : 2 : }
4208 : 6 : }
4209 : 83 :
4210 : 83 : /**
4211 : 83 : * Description Elements at datetime
4212 : 83 : *
4213 : 83 : * @method setIconAtDatetime
4214 : 83 : * @instance
4215 : 83 : * @memberof module:weather.Weather
4216 : 83 : * @param {string|number} dayInfo - A day identifier, which can be a date string (YYYY-MM-DD) or an index.
4217 : 83 : * @param {string|number} timeInfo - A time identifier, which can be a time string (HH:MM:SS) or an index.
4218 : 83 : * @param {string} value - The weather icon to be set.
4219 : 83 : * @desc Sets the weather icon for a specific datetime within the weather data.
4220 : 83 : * @throws {Error} Propagates any exceptions that may occur during the setting process.
4221 : 83 : */
4222 [ + ]: 83 : setIconAtDatetime(dayInfo, timeInfo, value){
4223 : 4 : try{
4224 : 4 : let dayItem = Weather.filterItemByDatetimeVal(this.#weatherData.days, dayInfo);
4225 [ + ]: 4 : dayItem && (Weather.filterItemByDatetimeVal(dayItem.hours, timeInfo).icon = value);
4226 : 4 : }
4227 [ + ]: 4 : catch(error){
4228 : 2 : throw error;
4229 : 2 : }
4230 : 4 : }
4231 : 83 : }
4232 : 1 :
4233 : 1 : Object.defineProperty(Weather.prototype, Symbol.toStringTag, {value: 'Weather', writable: false, enumerable: false, configurable: true});
|