# Live CKAN sensor data to Node-RED worldmap

**URL:** <https://discourse.nodered.org/t/live-ckan-sensor-data-to-node-red-worldmap/93517>\
**Category:** General\
**Tags:** function-node\
**Created:** [27 November 2024 13:21 UTC](https://discourse.nodered.org/t/live-ckan-sensor-data-to-node-red-worldmap/93517 "2024-11-27T13:21:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![540346411](https://avatars.discourse-cdn.com/v4/letter/5/b3f665/32.png) [@540346411](https://discourse.nodered.org/u/540346411)\
**Post date:** [27 November 2024 13:21 UTC](https://discourse.nodered.org/t/live-ckan-sensor-data-to-node-red-worldmap/93517/1 "2024-11-27T13:21:59Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2fc3f0e79283c7c87451afa32f96f93f1dbff867.png)

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 February 2025 13:22 UTC](https://discourse.nodered.org/t/live-ckan-sensor-data-to-node-red-worldmap/93517/2 "2025-02-25T13:22:04Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
