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