From d1fb11a0c043854a0c65e7876c532fa7c9e5c23c Mon Sep 17 00:00:00 2001 From: charitha Date: Tue, 31 Jul 2018 16:01:23 +0530 Subject: [PATCH] Improved geo fencing --- ...n-EventsFusionGenerateNotifications-1.0.0.siddhiql | 7 ++----- .../Geo-ExecutionPlan-Pass_through-1.0.0.siddhiql | 2 +- .../WSO2IoT-Geo-ExecutionPlan.siddhiql | 11 +++++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql index ec8ffd087c..36bbd52339 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-EventsFusionGenerateNotifications_1.0.0/Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql @@ -17,11 +17,8 @@ define stream alertsOut ( id string, state string, information string, timeStamp @Export('iot.per.device.stream.geo.FusedSpatialEvent:1.0.0') define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string, notify bool ); -from dataIn#window.geodashboard:eventsFusion(eventId, state, information) -insert into innerStream; - -from innerStream -select id, latitude, longitude, timeStamp, type, speed, heading, state , information, geodashboard:needToNotify(id,information) as notify +from dataIn +select id, latitude, longitude, timeStamp, type, speed, heading, state , information, (str:strcmp("ALERTED", state) == 0) as notify insert into dataOut; from dataOut[notify == true] diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-Pass_through_1.0.0/Geo-ExecutionPlan-Pass_through-1.0.0.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-Pass_through_1.0.0/Geo-ExecutionPlan-Pass_through-1.0.0.siddhiql index 9a2d344b90..aec39ac5c3 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-Pass_through_1.0.0/Geo-ExecutionPlan-Pass_through-1.0.0.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-ExecutionPlan-Pass_through_1.0.0/Geo-ExecutionPlan-Pass_through-1.0.0.siddhiql @@ -12,6 +12,6 @@ define stream dataIn (id string, latitude double, longitude double, timeStamp lo @Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0') define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string); -from dataIn#geodashboard:subscribe() +from dataIn select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "Normal driving pattern" as information insert into dataOut; \ No newline at end of file diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/WSO2IoT-Geo-ExecutionPlan_1.0.0/WSO2IoT-Geo-ExecutionPlan.siddhiql b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/WSO2IoT-Geo-ExecutionPlan_1.0.0/WSO2IoT-Geo-ExecutionPlan.siddhiql index 50718fc82e..1bfd0de600 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/WSO2IoT-Geo-ExecutionPlan_1.0.0/WSO2IoT-Geo-ExecutionPlan.siddhiql +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/WSO2IoT-Geo-ExecutionPlan_1.0.0/WSO2IoT-Geo-ExecutionPlan.siddhiql @@ -12,8 +12,11 @@ define stream dataIn (meta_deviceId string, meta_deviceType string, timeStamp long, latitude double, longitude double); @Export('org.wso2.geo.StandardSpatialEvents:1.0.0') -define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string ); +define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string); -from dataIn -select meta_deviceId as id, latitude, longitude, timeStamp, -meta_deviceType as type, 0.0f as speed, 0.0f as heading, UUID() as eventId insert into dataOut \ No newline at end of file +from every fs1=dataIn -> fs2=dataIn[fs2.timeStamp > fs1.timeStamp and fs1.meta_deviceId == fs2.meta_deviceId] +select fs1.meta_deviceId as id, fs2.latitude, fs2.longitude, fs2.timeStamp, fs1.meta_deviceType as type, +convert(geo:distance(fs2.latitude, fs2.longitude, fs1.latitude, fs1.longitude) * 3600/(fs2.timeStamp - fs1.timeStamp), 'float') as speed, +0.0f as heading, UUID() as eventId +group by fs1.meta_deviceId +insert into dataOut \ No newline at end of file