(Classic) Event Network Exercise: Semantic Translation
Objective
Process events to provide semantic translation for later processing
Setup
- Complete the Foursquare Checkin exercise.
- Complete the Data Storage exercise.
Exercise
- Create an event channel and label it "current location"
- Use the event channel ID to create an ESL that raises a location:current event with lat-long attributes
- Modify the
location
rule in the Personal Data Storage exercise to also store lat-long attributes from a Foursquare checkin - Create and register a ruleset:
- Write a rule called
nearby
that listens for the current:location event. - Use the great circle functions in the
math
library to calculate the distance between the lat-long coordinates from the PDS module and those reported with thelocation:new_current
event. - If the distance is less than a threshold (say 5 miles), then raise a
explicit:location_nearby
event otherwise raise aexplicit:location_far
event. Both events should contain the distance as an attribute.
- Write a rule called
- Install the ruleset you created in the preceding step
- Create and register a second ruleset that has a rule that listens for the
location:nearby
event that sends a text message (see the Twilio module documentation) with the distance to your phone. Make sure you install this ruleset as well. - Test by raising the
location:new_current
event using the ESL you designed. Be sure you've checked in with Foursquare since modifying the ruleset to store lat-long data.
This exercise previously named the location:new_current
event location:current
. The problem is that current
is a reserved word and the current parser doesn't allow reserved words as event names. Feel free to name it whatever makes sense, just document what it is.
Copyright Picolabs | Licensed under Creative Commons.