Hello there,
I'm trying to make a live map using real life data from a CKAN URL.
I have never used NODE-Red before, so i am a complete noob, but love it so far!
The problem I face is that the points on the map doesnt show the most recent sensor timestamp, but a random one. Even though I request the URL every minute through the timestamp.
This is how my project looks, the data I receive dont include coordinates/location attribute data, so I added them in NODE-Red based on the three different sensors:
This is how i added those coordinates to the three different points:
// Stap 5: Voeg geografische coördinaten toe aan elk record
let features = records.map(record => {
// Voeg coördinaten toe op basis van entity_id
let lat, lon;
// Voeg coördinaten toe op basis van entity_id
if (record.entity_id === "urn:nl.den-bosch.fitness-circus:em-310-tilt-springer-r") {
lat = 51.7221708;
lon = 5.3049023;
} else if (record.entity_id === "urn:nl.den-bosch.fitness-circus:em-320-tilt-spin-l") {
lat = 51.722225;
lon = 5.305009;
} else if (record.entity_id === "urn:nl.den-bosch.fitness-circus:em-400-tld-roei") {
lat = 51.722279;
lon = 5.305120;
} else {
return null;
}
This is what my function looks like so far for prioritising the newest Timestamp:
filteredRecords.sort((a, b) => {
// Controleer of beide timestamps bestaan
if (!a.recording_timestamp) return 1; // Records zonder timestamp achteraan
if (!b.recording_timestamp) return -1; // Records zonder timestamp achteraan
// Converteer naar datumobjecten en sorteer op nieuw naar oud
return new Date(b.recording_timestamp).getTime() - new Date(a.recording_timestamp).getTime();
});
So once again my problem I face is that the points on the map doesnt show the most recent sensor timestamp, but a random one.