Ever heard about that hotel that didn’t have the 13th floor? Empty superstition, I don’t believe in things like that. Now where was I? Yes, GPS data to Coral8 — here we go.
Having done my homework in the previous post, this should not be too complicated. For the template I have chosen: entity, latitude, longitude, course, speed and the time stamp. The first thing I noticed is that my time format does not match the format used by Coral8. After few trail and error attempts, I have decided to transfer the time stamp to the server as a string, and later convert it to the time format. For this I needed an additional local stream.
-- Input from GPS CREATE INPUT STREAM GpsIn SCHEMA ( Entity STRING ,Latitude FLOAT ,Longitude FLOAT ,Course FLOAT ,Speed FLOAT ,TimeUTC STRING ); -- Local formatted stream with -- TimeUTC as TIMESTAMP CREATE LOCAL STREAM GpsFmtd SCHEMA ( Entity STRING ,Latitude FLOAT ,Longitude FLOAT ,Course FLOAT ,Speed FLOAT ,TimeUTC TIMESTAMP ); -- Output stream CREATE OUTPUT STREAM StreamOut SCHEMA ( Entity STRING ,Latitude FLOAT ,Longitude FLOAT ,Course FLOAT ,Speed FLOAT ,TimeUTC TIMESTAMP );
The only purpose of the local GpsFmtd stream is to allow conversion of the TimeUTC field from a string to the proper time format. With streams in place, I can add queries to connect them.
-- From Input to Local INSERT INTO GpsFmtd SELECT Entity ,Latitude ,Longitude ,Course ,Speed ,TO_TIMESTAMP(TimeUTC) FROM GpsIn; -- From Local to Output INSERT INTO StreamOut SELECT * FROM GpsFmtd;
Here is the flow view.
This is all for the Coral8 side, now the Python code. Being on my local network, there is no need for an authorization module. I will need only template and service modules:
As in all previous examples, the service has to be activated in the main gps_event.py module:
# select service: none, aws, rc, tweet, email, gtalk, coral8, wp, blog use_service = 'coral8' # define sampling delay in seconds sample_delay = 5
And here is the result. You may notice different display of the TimeUTC field. The top one is a string — as sent to the server — while the bottom one is in the Coral8 TIMESTAMP format.
In Coral8 terminology this would be called a GPS out-of-process adapter.
To be continued.