* Traverses all the pages that make up the response from a SensorThingsAPI instance. The link to the next page, if present, is denoted by the presence of a "@iot.nextLink" property in the response object. This function concatenates all the values so that the complete results are returned in one array.
// The negative index should remove these nine characters: ` DS:60min`
returndatastreamName.slice(0,-9);
};
/**
* Format the response containing a Datastream's metadata from Sensorthings API
* @param {Object} datastreamMetadata An object containing a Datastream's metadata
* @param {Boolean} isMetadataForAggregation A flag to determine if the datastream metadata will be used for aggregation. Set to `true` if metadata will be used for aggregation, `false` if not
* @returns {Object} An object containing the formatted metadata that is suitable for use in a chart
*/
constformatDatastreamMetadataForChart=function(
datastreamMetadata,
isMetadataForAggregation
){
if(
datastreamMetadata===undefined||
isMetadataForAggregation===undefined
)
thrownewError(
"This function expects two arguments, ensure that both have been supplied"
// Case 1: Metadata NOT USED for aggregation; "isMetadataForAggregation" = false
if(!isMetadataForAggregation)
return{
datastreamDescription,
datastreamName,
phenomenonName,
unitOfMeasurementSymbol,
};
// Case 2: Metadata USED for aggregation; "isMetadataForAggregation" = true
return{
datastreamDescription,
datastreamName,
buildingIdPhenomenonName,
unitOfMeasurementSymbol,
};
};
/**
* Extract the properties that make up the formatted datastream metadata object(s)
* @param {Array} formattedDatastreamsMetadataArr An array of formatted metadata object(s) from one or more datastreams
* @param {Boolean} isMetadataForAggregation A flag to determine if the datastream metadata will be used for aggregation. Set to `true` if metadata will be used for aggregation, `false` if not
* @param {String} [aggregationInterval] The aggregation interval as a string, either "daily" or "monthly". Required when `isMetadataForAggregation = true`
* @param {String} [aggregationType] The aggregation type as a string, either "sum" or "average". Required when `isMetadataForAggregation = true`
* @returns {Object} An object that contains array(s) of formatted datastream metadata properties