Commit 268a2bbc authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

Add function that maps building number to datastream ID

parent a843435a
...@@ -6,6 +6,72 @@ ...@@ -6,6 +6,72 @@
const BASE_URL = "http://193.196.39.91:8080/frost-icity-tp31/v1.1"; const BASE_URL = "http://193.196.39.91:8080/frost-icity-tp31/v1.1";
const getDatastreamIdFromBuildingNumber = function (
buildingNumber,
phenomenon,
samplingRate
) {
// Ensure that building number passed here is numeric
if (!Number.isInteger(buildingNumber)) return;
const buildingToDatastreamMapping = {
101: {
vl: { "15min": "69", "60min": "75" },
rl: { "15min": "81", "60min": "87" },
flow: { "15min": "93", "60min": "99" },
power: { "15min": "105", "60min": "111" },
energy: { "15min": "117", "60min": "123" },
energy_verb: { "15min": "129", "60min": "135" },
},
102: {
vl: { "15min": "70", "60min": "76" },
rl: { "15min": "82", "60min": "88" },
flow: { "15min": "94", "60min": "100" },
power: { "15min": "106", "60min": "112" },
energy: { "15min": "118", "60min": "124" },
energy_verb: { "15min": "130", "60min": "136" },
},
107: {
vl: { "15min": "71", "60min": "77" },
rl: { "15min": "83", "60min": "89" },
flow: { "15min": "95", "60min": "101" },
power: { "15min": "107", "60min": "113" },
energy: { "15min": "119", "60min": "125" },
energy_verb: { "15min": "131", "60min": "137" },
},
"112_118": {
vl: { "15min": "72", "60min": "78" },
rl: { "15min": "84", "60min": "90" },
flow: { "15min": "96", "60min": "102" },
power: { "15min": "108", "60min": "114" },
energy: { "15min": "120", "60min": "126" },
energy_verb: { "15min": "132", "60min": "138" },
},
125: {
vl: { "15min": "73", "60min": "79" },
rl: { "15min": "85", "60min": "91" },
flow: { "15min": "97", "60min": "103" },
power: { "15min": "109", "60min": "115" },
energy: { "15min": "121", "60min": "127" },
energy_verb: { "15min": "133", "60min": "139" },
},
225: {
vl: { "15min": "74", "60min": "80" },
rl: { "15min": "86", "60min": "92" },
flow: { "15min": "98", "60min": "104" },
power: { "15min": "110", "60min": "116" },
energy: { "15min": "122", "60min": "128" },
energy_verb: { "15min": "134", "60min": "140" },
},
};
const datastreamIdMatched = Number(
buildingToDatastreamMapping[buildingNumber][phenomenon][samplingRate]
);
return datastreamIdMatched;
};
/** /**
* Create URL to fetch the Observations corresponding to a provided Datastream * Create URL to fetch the Observations corresponding to a provided Datastream
* @param {Number} datastreamID - Integer representing the Datastream ID * @param {Number} datastreamID - Integer representing the Datastream ID
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment