Removing negative latitude and longitude coordinates


My Gps Sensor is sending 2 payloads of messages containing latitude and longitude at the same time.So want to remove the extra latitude and longitude coordinates.
Here is the flow
flows.json (632 Bytes)

When posting a flow please use the </> button at the top of the edit window and paste the flow in.

Are there two messages coming out of the MQTT node?

yes collin 2 messages are coming from mqtt node.the first coordintes are correct as you can see on map.{"lat":28.39207763671875,"lon":76.95928548177083,"name":"apple","icon":"fa-truck","layer":"marker"}

How are they getting into mqtt?

from gps tracker->gateway->mqtt broker(cloud)->node red mqtt subscribe node.
basically gps tracker is sending 2 packets each time its send.the first one is correct and second one is some absurd value.

Is there some way that you can tell by looking at the values that they are absurd? In the first image I see it has an illegal lon value, but the second image has lat 6, lon -1.3 which is not intrinsically absurd. If you can say how you know that it is absurd then you can use a switch node to only pass valid ones.

Maybe if you put debug node to somewhere earlier in that flow, there might be more info about the message content which can then be used as filter

Alternatively if it is always the second one that is to be discarded and it always appears within a short time of the first one then you could use a Trigger node set to send the message immediately then after, say 5 seconds, send nothing and with Extend Delay checked so that it will throw away an message appearing with 5 seconds of the first one.


how to set trigger node so that message 2nd can be discarded after a time interval of 5 sec or so.?

You should set 'then send' to Nothing (it is one of the dropdown options), as you have it it will send a message with a payload of "0". Also you have the delay set to 250 msec rather than 5 seconds.

this is the output

The "0" is because you haven't changed the Then Send setting as I said. Also put the trigger on the output of the mqtt, there is no point feeding it through all the other nodes then discarding it. However, before doing that can you put the debug on the mqtt node and show us exactly what is coming out of that please?



This is the output when debud node placed after mqtt node.

Those have got lat and lon as 0.
Also why do you not just set the output of mqtt node to parsed json and then you will get the values directly in a javascript object? No need for the base64 and buffer parser unless I am missing something.

Sorry, I am still getting back up to speed. Been away for 2 weeks.

Dumb question: Why do you want to remove the - number/s from the longitude values?

He/she is trying to get rid of what appear to be faulty position values, but I am not convinced they are there in the existing data which is why we are looking at what is coming out of the MQTT need before working out what the solution is.

Seems to me that you have 2 data packets and they carry different information.

http://doc.mokotechnology.com/index.php?s=/2&page_id=11.

The first one holds location data, the second one has movement and battery info in it. But to make sure which one you have currently in processing, it can be read out from that binary.
So read the doc and follow the rules.

Thanks.

I maybe should have looked deeper into the thread.

I believe you are correct. It seems there are extraneous packets in there.

Correct:
Determining from where they are coming would be better.

Maybe stick a debug node on the MQTT IN node and display the entire message.

I think I'll shut up. My brain is really not with me just now.

How about you post the actual data rather than a screen shot?