Publishing and Receiving CSV Events via Files¶
Purpose¶
This example demonstrates how to calculate the distance between two locations via the siddhi-gpl-execution-geo extension.
Before you begin:
- Download the siddhi-gpl-execution-geo-x.x.x.jar and place it in the
<SI_HOME>/libdirectory. - Save this sample in WSO2 Integrator: SI Tooling.
Executing the Sample¶
To execute the sample open the saved Siddhi application in WSO2 Integrator: SI Tooling, and start it by clicking the Start button (shown below) or by clicking Run => Run.

If the Siddhi application starts successfully, the following message appears in the console.
GeoDistanceCalculation.siddhi - Started Successfully!
Testing the Sample¶
To test the sample application, simulate a single event for it as follows:
-
To open the Event Simulator, click the Event Simulator icon.

This opens the event simulation panel.
-
To simulate events for the
LocationPointsStreamstream of theGeoDistanceCalculationSiddhi application, enter information in the Single Simulation tab of the event simulation panel as follows.Field Value Siddhi App Name GeoDistanceCalculationStreamName LocationPointsStream
As a result, the attributes of the
GeoDistanceCalculationstream appear in the panel. -
Enter attribute values as follows.
.
| Attribute | Value |
|---|---|
| latitude | 8.116553 |
| longitude | 77.523679 |
| prevLatitude | 9.850047 |
| prevLongitude | 98.597177 |
- Send the event
Viewing the Results¶
The following output is logged inthe WSO2 Integrator: SI console for the single event you simulated.
INFO {io.siddhi.core.query.processor.stream.LogStreamProcessor} - GeoDistanceCalculation: Event :, StreamEvent{ timestamp=1513616078228, beforeWindowData=null, onAfterWindowData=null, outputData=[2322119.848252557], type=CURRENT, next=null}
Click here to view the sample Siddhi application.
@App:name("GeoDistanceCalculation")
@App:description('This will demonstrate the distance between two locations')
define stream LocationPointsStream (latitude double, longitude double, prevLatitude double, prevLongitude double);
@sink(type='log')
define stream DistanceStream (distance double);
@info(name = 'query1')
from LocationPointsStream
select geo:distance(latitude, longitude, prevLatitude, prevLongitude) as distance
insert into DistanceStream;