Form a GeoJson Point with Lat/Long Values

Hello, as shown bellow I am getting the latitude and longitude values from my Mqtt with regex (which I can’t change to match the exact format of a geojson point) What I would like to know is if it is possible to form the structure of a point based on two other values or extracting the two values with regex and join them into a json structure.

Finally, I’d like to know if there’s is any way for the last value recorded to stay as it is, when the new value is null.
This is the structure I want to make:

{ “type”:“Point”, “coordinates”: [4.585222000000789, 51.91327390361854] }

Hi Jonathan,

the only thing what comes in my mind would be:

Do a python job as mqtt client to the broker, which is subscribed to the Attributes: Latitude and Longtitude

Then publish the payloads to the location:

double latitude = (PayloadOfLatitude);
double longitude = (PayloadOfLongtitude);
char mqtt_payload[100] = “”;
snprintf (mqtt_payload, 100, “{ "type":"Point", "coordinates":[ %lf, %lf\n]}”, longitude, latitude);
client.publish(pubTopic, mqtt_payload);

Sorry, there is no out of the Box solution. :frowning:

1 Like

I ran into the same issue, with an HTTP API, the coordinates are in separate fields in the JSON data.

I managed to use a FLOW rule to concatenate the bits of text into the correct format: {“type”: “Point”, “coordinates”: [28.327645,-25.789431]}

Then just write it to the location attribute on my asset.

1 Like