forked from community/device-mgt-core
parent
1ffaad6fb7
commit
8c303911b0
@ -1,25 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.common.geo.service;
|
||||
|
||||
/**
|
||||
* Custom exception class of Geo Service related operations.
|
||||
*/
|
||||
|
||||
public class AlertAlreadyExist extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 4709355511911265093L;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public AlertAlreadyExist(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
|
||||
var log = new Log("geo-devices.js");
|
||||
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
var viewModel = {};
|
||||
var carbonServer = require("carbon").server;
|
||||
var device = context.unit.params.device;
|
||||
var constants = require("/app/modules/constants.js");
|
||||
var wsEndpoint = null;
|
||||
var jwtService = carbonServer.osgiService(
|
||||
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
|
||||
var jwtClient = jwtService.getJWTClient();
|
||||
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]);
|
||||
var tokenPair = null;
|
||||
var token = "";
|
||||
if (encodedClientKeys) {
|
||||
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
|
||||
var resp = tokenUtil.decode(encodedClientKeys).split(":");
|
||||
if (context.user.domain == "carbon.super") {
|
||||
tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {});
|
||||
if (tokenPair) {
|
||||
token = tokenPair.accessToken;
|
||||
wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/";
|
||||
}
|
||||
} else {
|
||||
tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + context.user.domain,"default", {});
|
||||
if (tokenPair) {
|
||||
token = tokenPair.accessToken;
|
||||
wsEndpoint = devicemgtProps["wssURL"].replace("https", "wss") + "/secured-websocket/t/"+context.user.domain+"/";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
viewModel.device = device;
|
||||
viewModel.wsToken = token;
|
||||
viewModel.wsEndpoint = wsEndpoint;
|
||||
viewModel.geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.enabled;
|
||||
return viewModel;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h4>
|
||||
Set 'Exit Fence' alerts
|
||||
<br>
|
||||
</h4>
|
||||
</div>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-centered">
|
||||
<div class="">
|
||||
<table class="table table-hover" id="exit-alert">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fence Name</th>
|
||||
<th>Query Name</th>
|
||||
<th>Created On</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<div class="alert alert-info fence-not-exist" role="alert">
|
||||
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
|
||||
</div>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
<button style="background-color: #f4f4f4; float: left" type="button" class="btn btn-default"
|
||||
onclick="viewAllFences('Exit')">View All
|
||||
</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="openTools('Exit')">Draw area
|
||||
</button>
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="$('#editExitGeoJSON').modal('toggle')">Enter area
|
||||
</button>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/devicemgt/public/cdmf.unit.geo-devices/js/geo_exit_fence.js"></script>
|
@ -0,0 +1,95 @@
|
||||
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<link href="/portal/store/carbon.super/fs/gadget/geo-devices/css/leaflet/L.Grid.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="/portal/store/carbon.super/fs/gadget/geo-devices/css/main.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="/portal/store/carbon.super/fs/gadget/geo-devices/js/leaflet/L.Grid.js"></script>
|
||||
<script src="/portal/store/carbon.super/fs/gadget/geo-devices/js/leaflet/L.MeasuringTool.js"></script>
|
||||
<style>
|
||||
.leaflet-grid-label .lng {
|
||||
margin-left: 8px;
|
||||
-webkit-transform: rotate(90deg);
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.measuring-line-for-look {
|
||||
stroke-dasharray: 3, 20;
|
||||
}
|
||||
|
||||
.measuring-label-tooltip .leaflet-popup-content-wrapper {
|
||||
border-radius: 4px 4px 4px 4px;
|
||||
opacity: 0.7;
|
||||
padding: 1px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.measuring-label-tooltip .leaflet-popup-content {
|
||||
margin: 0 5px;
|
||||
/*width: 0;*/
|
||||
}
|
||||
|
||||
.measuring-label-tooltip .leaflet-popup-tip-container {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal-header"
|
||||
style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">
|
||||
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
|
||||
Define proximity
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="proximityMap" style="height: 50%; margin: 0 auto;"></div>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<form class="form-inline" role="form">
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" id="proximityDistance" class="form-control" placeholder="Distance" >
|
||||
<span class="input-group-addon">m</span>
|
||||
</div>
|
||||
<div class="input-group input-group-sm">
|
||||
<input autofocus="enable" id="proximityTime" type="number" class="form-control"
|
||||
placeholder="Close time in S" >
|
||||
<span class="input-group-addon">Seconds</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: -15px" class="btn-group btn-group-justified">
|
||||
<div class="btn-group">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="setProximityAlert()">Set Proximity
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="closeAll()">Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/portal/store/carbon.super/fs/gadget/geo-devices/js/geo_proximity.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,49 @@
|
||||
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h4>
|
||||
Setup global speed limit
|
||||
<br>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<div class="input-group input-group-sm">
|
||||
<input autofocus="enable" id="speedAlertValue" type="number" min="0" class="form-control" placeholder="Speed alert value " autocomplete="off">
|
||||
<span class="input-group-addon">km/h</span>
|
||||
</div>
|
||||
<br>
|
||||
<button type="button" class="btn btn-default pull-right btn-sm" onclick="closeAll()">Cancel</button>
|
||||
<button type="button" class="btn btn-info pull-right btn-sm" onclick="setSpeedAlert()" style="margin-right: 10px;">Set speed alert</button>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/devicemgt/public/cdmf.unit.geo-devices/js/geo_speed.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,83 @@
|
||||
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<style>
|
||||
.fa-trash-o:hover {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h4>
|
||||
Set 'Stationary' alerts
|
||||
<br>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-centered">
|
||||
<div class="">
|
||||
<table class="table table-hover" id="stationary-alert-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stationary Name</th>
|
||||
<th>Stationary Time</th>
|
||||
<th>Fluctuation Radius</th>
|
||||
<th>Query Name</th>
|
||||
<th>Created On</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<div class="alert alert-info fence-not-exist" role="alert">
|
||||
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
<button style="background-color: #f4f4f4; float: left" type="button" class="btn btn-default"
|
||||
onclick="viewAllFences('Stationery')">View All
|
||||
</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="openTools('Stationery')">Draw area
|
||||
</button>
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="$('#editWithinGeoJSON').modal('toggle')">Enter area
|
||||
</button>
|
||||
</div>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/devicemgt/public/cdmf.unit.geo-devices/js/geo_stationary.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,104 @@
|
||||
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<style>
|
||||
.fa-trash-o:hover{color:red;}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$(".removeGeoFence").tooltip();
|
||||
|
||||
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
|
||||
viewFence(this.parentElement,'Traffic');
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal-header" style="cursor: move;background: #f9f9f9;-webkit-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);-moz-box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);box-shadow: inset 0px 0px 14px 1px rgba(0,0,0,0.2);">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">
|
||||
<!-- TODO: Trigger bootstrap tooltip $('#aboutTileUrl').tooltip(); to enable tooltip -->
|
||||
Set <i>traffic</i> alerts
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
|
||||
<p class="text-info text-center">View current fences</p>
|
||||
<div class="">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr >
|
||||
<th>Query Name</th>
|
||||
<th>Traffic Congestion Area Name</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<%
|
||||
var alerts = get('traffic');
|
||||
if(alerts){
|
||||
for each(var alert in alerts){
|
||||
%>
|
||||
<tr class="viewGeoFenceRow" style="cursor: pointer" data-areaName='<%= alert.areaName %>' data-queryName='<%= alert.queryName %>' data-geoJson='<%= alert.geoJson %>'>
|
||||
<td><%= alert.queryName %></td>
|
||||
<td><%= alert.areaName %></td>
|
||||
<td onClick="removeGeoFence(this.parentElement,'Traffic')" class="removeGeoFence" data-toggle="tooltip" title="Remove fence" ><i class="fa fa-trash-o"></i></td>
|
||||
</tr>
|
||||
<%
|
||||
}
|
||||
}
|
||||
else{
|
||||
%>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="text-info text-center">Select Interested Area</p>
|
||||
|
||||
<div style="margin-bottom: -15px" class="btn-group btn-group-justified">
|
||||
<div class="btn-group">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="openTools('Traffic')">Draw area</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="$('#editWithinGeoJSON').modal('toggle')" >Enter area</button>
|
||||
</div>
|
||||
<!--<div class="btn-group">-->
|
||||
<!--<button style="background-color: #f4f4f4;" type="button" class="btn btn-default" onclick="closeAll()">Cancel</button>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,52 @@
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h4>
|
||||
Set 'Within' alerts
|
||||
<br>
|
||||
</h4>
|
||||
</div>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-md-8 col-centered">
|
||||
<div class="">
|
||||
<table class="table table-hover" id="within-alert">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fence Name</th>
|
||||
<th>Query Name</th>
|
||||
<th>Created On</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<div class="alert alert-info fence-not-exist" role="alert">
|
||||
<strong>Oh snap!</strong> Can't find any geofence area, please draw a new area or try again.
|
||||
</div>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
<button style="background-color: #f4f4f4; float: left" type="button" class="btn btn-default"
|
||||
onclick="viewAllFences('WithIn')">View All
|
||||
</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="openTools('WithIn')">Draw area
|
||||
</button>
|
||||
<button style="background-color: #f4f4f4;" type="button" class="btn btn-default"
|
||||
onclick="$('#editWithinGeoJSON').modal('toggle')">Enter area
|
||||
</button>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/devicemgt/public/cdmf.unit.geo-devices/js/geo_within.js"></script>
|
@ -0,0 +1,52 @@
|
||||
<!--~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="viewExitAlert" >
|
||||
<h3 class="popover-title" id="viewAreaName"></h3>
|
||||
<div class="popover-content">
|
||||
<form role="form" style="width: auto" id="exitAlertForm">
|
||||
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
|
||||
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="viewWithinAlert" >
|
||||
<h3 class="popover-title" id="viewAreaName"></h3>
|
||||
<div class="popover-content">
|
||||
<form role="form" style="width: auto" class="" id="withinAlertForm">
|
||||
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
|
||||
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="viewStationeryAlert" >
|
||||
<h3 class="popover-title" id="viewAreaName"></h3>
|
||||
<div class="popover-content">
|
||||
<form role="form" style="width: auto" id="stationaryAlertForm">
|
||||
<h6>Stationery time(Seconds)<span id="viewAreaTime" class="label label-primary pull-right">N/A</span></h6>
|
||||
<button type="button" id="exportGeoJson" download="geoJson.json" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</button>
|
||||
<button type="button" id="hideViewFence" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,20 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('$executionPlanName')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
|
||||
|
||||
@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[geo:within(longitude,latitude,"$geoFenceGeoJSON")==false and id == "$deviceId"]#geodashboard:subscribe()
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
|
||||
insert into dataOut;
|
||||
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=false and id == "$deviceId"]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
|
||||
insert into dataOut;
|
@ -0,0 +1,140 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('Geo-ExecutionPlan-Proximity_alert')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string );
|
||||
|
||||
@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 );
|
||||
|
||||
@IndexBy('id')
|
||||
define table ProximityTable(id string, timeStamp long);
|
||||
|
||||
@IndexBy('id')
|
||||
define table AlertsTable(id string , proximityWith string, eventId string);
|
||||
|
||||
from dataIn#geodashboard:subscribe()
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId
|
||||
insert into initialStream;
|
||||
|
||||
from initialStream[type == 'STOP']
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
|
||||
insert into dataOutStream;
|
||||
|
||||
from initialStream[type != 'STOP']
|
||||
select *
|
||||
insert into objectInitialStream;
|
||||
|
||||
from objectInitialStream#geo:proximity(id,longitude,latitude, $proximityDistance)
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith
|
||||
insert into proxymityStream;
|
||||
|
||||
from proxymityStream[AlertsTable.id == proxymityStream.id in AlertsTable]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
|
||||
insert into innerStreamOne;
|
||||
|
||||
from proxymityStream[not(AlertsTable.id == proxymityStream.id in AlertsTable)]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
|
||||
insert into innerStreamOne;
|
||||
|
||||
from proxymityStream[AlertsTable.id == proxymityStream.proximityWith in AlertsTable]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
|
||||
insert into innerStreamSeven;
|
||||
|
||||
from proxymityStream[not(AlertsTable.id == proxymityStream.proximityWith in AlertsTable)]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
|
||||
insert into innerStreamSeven;
|
||||
|
||||
from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
|
||||
select id,str:concat(",",proximityWith) as proximityWith , eventId
|
||||
insert into AlertsTable;
|
||||
|
||||
from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
|
||||
select proximityWith as id,str:concat(",",id) as proximityWith , eventId
|
||||
insert into AlertsTable;
|
||||
|
||||
from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
|
||||
on innerStreamOne.id == AlertsTable.id
|
||||
select innerStreamOne.id as id, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
|
||||
insert into updateStream;
|
||||
|
||||
from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
|
||||
on innerStreamSeven.proximityWith == AlertsTable.id
|
||||
select innerStreamSeven.proximityWith as id, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
|
||||
insert into updateStream;
|
||||
|
||||
from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
|
||||
on innerStreamOne.id == AlertsTable.id
|
||||
select innerStreamOne.id as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
|
||||
insert into updateStream;
|
||||
|
||||
from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
|
||||
on innerStreamSeven.proximityWith == AlertsTable.id
|
||||
select innerStreamSeven.proximityWith as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
|
||||
insert into updateStream;
|
||||
|
||||
from updateStream
|
||||
select *
|
||||
update AlertsTable
|
||||
on id== AlertsTable.id;
|
||||
|
||||
from updateStream[proximityWith == ""]
|
||||
delete AlertsTable
|
||||
on id== AlertsTable.id;
|
||||
|
||||
from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, true as inAlertTable
|
||||
insert into publishStream;
|
||||
|
||||
from objectInitialStream[not(AlertsTable.id == objectInitialStream.id in AlertsTable)]
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, false as inAlertTable
|
||||
insert into publishStream;
|
||||
|
||||
from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
|
||||
on publishStream.id== AlertsTable.id
|
||||
select publishStream.id as id, publishStream.latitude as latitude, publishStream.longitude as longitude, publishStream.timeStamp as timeStamp, publishStream.type as type, publishStream.speed as speed, publishStream.heading as heading, publishStream.eventId as eventId, AlertsTable.proximityWith as proximityInfo
|
||||
insert into innerStreamTwo;
|
||||
|
||||
from publishStream[inAlertTable == false]
|
||||
delete ProximityTable on ProximityTable.id==id;
|
||||
|
||||
from publishStream[inAlertTable == false]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
|
||||
insert into innerStreamThree;
|
||||
|
||||
from innerStreamThree#window.length(0) join ProximityTable
|
||||
on innerStreamThree.id == ProximityTable.id
|
||||
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId, ProximityTable.timeStamp as storedTime, innerStreamThree.proximityInfo as proximityInfo
|
||||
insert into innerStreamFour;
|
||||
|
||||
from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,proximityInfo,"true" as isProximity
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamFour[(timeStamp - storedTime) < $proximityTime]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , proximityInfo ,"false" as isProximity
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
|
||||
select innerStreamTwo.id, innerStreamTwo.timeStamp
|
||||
insert into ProximityTable;
|
||||
|
||||
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
|
||||
insert into dataOutStream;
|
||||
|
||||
from dataOutStream[isProximity == 'true']
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,"WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information
|
||||
insert into dataOut;
|
||||
|
||||
from dataOutStream[isProximity == 'false']
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
|
||||
insert into dataOut;
|
@ -0,0 +1,20 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('Geo-ExecutionPlan-Speed---$deviceId_alert')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
|
||||
|
||||
@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[speed >= $speedAlertValue and id == "$deviceId"]#geodashboard:subscribe()
|
||||
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "ALERTED" as state, "This device movement is not normal!!" as information
|
||||
insert into dataOut;
|
||||
from dataIn[speed < $speedAlertValue and id == "$deviceId"]
|
||||
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information
|
||||
insert into dataOut;
|
@ -0,0 +1,89 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('$executionPlanName')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
|
||||
|
||||
|
||||
@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);
|
||||
|
||||
@IndexBy('id')
|
||||
define table StationeryTable(id string, timeStamp long);
|
||||
|
||||
@IndexBy('id')
|
||||
define table AlertsTable(id string, stationary bool);
|
||||
|
||||
from dataIn#geodashboard:subscribe()
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,geo:within(longitude,latitude,"$geoFenceGeoJSON") as isWithin
|
||||
insert into innerStreamOne;
|
||||
|
||||
from innerStreamOne[isWithin == false]
|
||||
delete StationeryTable on StationeryTable.id==id;
|
||||
|
||||
from innerStreamOne[isWithin == false]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamOne[isWithin == true]#geo:stationary(id,longitude,latitude, $fluctuationRadius)
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,stationary
|
||||
insert into innerStreamTwo;
|
||||
|
||||
from innerStreamTwo[innerStreamTwo.stationary == true]
|
||||
select innerStreamTwo.id, innerStreamTwo.stationary
|
||||
insert into AlertsTable;
|
||||
|
||||
from innerStreamTwo[innerStreamTwo.stationary == false]
|
||||
delete AlertsTable on AlertsTable.id==id;
|
||||
|
||||
from innerStreamTwo[innerStreamTwo.stationary == false]
|
||||
delete StationeryTable on StationeryTable.id==id;
|
||||
|
||||
from innerStreamOne[isWithin == true AND not(AlertsTable.id == innerStreamOne.id in AlertsTable)]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamOne[isWithin == true AND AlertsTable.id == innerStreamOne.id in AlertsTable]
|
||||
insert into innerStreamThree;
|
||||
|
||||
from innerStreamThree#window.length(0) join AlertsTable
|
||||
on innerStreamThree.id == AlertsTable.id
|
||||
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId
|
||||
insert into innerStreamFour;
|
||||
|
||||
from innerStreamFour[not(StationeryTable.id == innerStreamFour.id in StationeryTable)]
|
||||
select innerStreamFour.id, innerStreamFour.timeStamp
|
||||
insert into StationeryTable;
|
||||
|
||||
from innerStreamOne[isWithin == true AND not(StationeryTable.id == innerStreamOne.id in StationeryTable)]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamOne[isWithin == true AND StationeryTable.id == innerStreamOne.id in StationeryTable]
|
||||
insert into innerStreamFive;
|
||||
|
||||
from innerStreamFive#window.length(0) join StationeryTable
|
||||
on innerStreamFive.id == StationeryTable.id
|
||||
select innerStreamFive.id , innerStreamFive.latitude, innerStreamFive.longitude,innerStreamFive.timeStamp, innerStreamFive.type, innerStreamFive.speed, innerStreamFive.heading ,innerStreamFive.eventId, StationeryTable.timeStamp as storedTime
|
||||
insert into innerStreamSix;
|
||||
|
||||
from innerStreamSix[(timeStamp - storedTime) >= $stationeryTime]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"true" as isStationary
|
||||
insert into dataOutStream;
|
||||
|
||||
from innerStreamSix[(timeStamp - storedTime) < $stationeryTime]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"false" as isStationary
|
||||
insert into dataOutStream;
|
||||
|
||||
from dataOutStream[isStationary == 'true']
|
||||
select id ,latitude, longitude,timeStamp, type, speed, heading ,eventId ,"ALERTED" as state, "This device is in $stationeryName area!!!" as information
|
||||
insert into dataOut;
|
||||
|
||||
from dataOutStream[isStationary == 'false']
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
|
||||
insert into dataOut;
|
@ -0,0 +1,17 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('$executionPlanName')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('rawGeoStream:1.0.0')
|
||||
define stream dataIn (id string, timeStamp long, geometry string, state string, information string);
|
||||
|
||||
@Export('AlertsNotifications:1.0.0')
|
||||
define stream dataOut (id string, state string, information string, timeStamp long, latitude double, longitude double);
|
||||
|
||||
from dataIn[geo:intersects(geometry, "$geoFenceGeoJSON")==true and geodashboard:needToNotify(id, str:concat(information, state), "sendFirst") == true and id == $deviceId]
|
||||
select id, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
|
||||
insert into dataOut
|
@ -0,0 +1,20 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('$executionPlanName')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
|
||||
|
||||
@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[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe()
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
|
||||
insert into dataOut;
|
||||
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"]
|
||||
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
|
||||
insert into dataOut;
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var ApplicationOptions = {
|
||||
colors: {
|
||||
states: {
|
||||
NORMAL: 'blue',
|
||||
WARNING: 'blue',
|
||||
OFFLINE: 'grey',
|
||||
ALERTED: 'red',
|
||||
UNKNOWN: 'black'
|
||||
},
|
||||
application: {
|
||||
header: 'grey'
|
||||
}
|
||||
},
|
||||
constance:{
|
||||
CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'iot.per.device.stream.geo.FusedSpatialEvent',
|
||||
CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.AlertsNotifications',
|
||||
CEP_Traffic_STREAM_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'DefaultWebsocketOutputAdaptorOnTrafficStream',
|
||||
CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket',
|
||||
TENANT_INDEX: 't',
|
||||
COLON : ':',
|
||||
PATH_SEPARATOR : '/',
|
||||
VERSION: '1.0.0',
|
||||
SPEED_HISTORY_COUNT: 20,
|
||||
NOTIFY_INFO_TIMEOUT: 1000,
|
||||
NOTIFY_SUCCESS_TIMEOUT: 1000,
|
||||
NOTIFY_WARNING_TIMEOUT: 3000,
|
||||
NOTIFY_DANGER_TIMEOUT: 5000
|
||||
},
|
||||
messages:{
|
||||
app:{
|
||||
|
||||
}
|
||||
},
|
||||
leaflet: {
|
||||
iconUrls: {
|
||||
//TODO path needs to be changed
|
||||
normalMovingIcon: '/img/markers/object-types/default/moving/alerted.png',
|
||||
alertedMovingIcon: '/img/markers/moving/arrow_alerted.png',
|
||||
offlineMovingIcon: '/img/markers/moving/arrow_offline.png',
|
||||
warningMovingIcon: '/img/markers/moving/arrow_warning.png',
|
||||
defaultMovingIcon: '/img/markers/moving/arrow_normal.png',
|
||||
|
||||
normalNonMovingIcon: '/img/markers/non_moving/dot_normal.png',
|
||||
alertedNonMovingIcon: '/img/markers/non_moving/dot_alerted.png',
|
||||
offlineNonMovingIcon: '/img/markers/non_moving/dot_offline.png',
|
||||
warningNonMovingIcon: '/img/markers/non_moving/dot_warning.png',
|
||||
defaultNonMovingIcon: '/img/markers/non_moving/dot_normal.png',
|
||||
|
||||
normalPlaceIcon: '/img/markers/places/marker-icon.png',
|
||||
alertedPlaceIcon: '/img/markers/places/redMarker.png',
|
||||
offlinePlaceIcon: '/img/markers/places/ashMarker.png',
|
||||
warningPlaceIcon: '/img/markers/places/pinkMarker.png',
|
||||
defaultPlaceIcon: '/img/markers/places/marker-icon.png',
|
||||
|
||||
defaultIcon: '/img/markers/moving/default_icons/marker-icon.png',
|
||||
resizeIcon: '/img/markers/resize.png',
|
||||
stopIcon: '/img/markers/stopIcon.png'
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Masayuki Tanaka
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,26 @@
|
||||
Copyright (c) 2010-2014, Michael Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name Michael Bostock may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,8 @@
|
||||
$(function() {
|
||||
$("#timeFromCal").datepicker({
|
||||
orientation: 'top'
|
||||
});
|
||||
$("#timeToCal").datepicker({
|
||||
orientation: 'top'
|
||||
});
|
||||
});
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function initializeExit() {
|
||||
$(".removeGeoFence").tooltip();
|
||||
$("#exit-alert > tbody").empty();
|
||||
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Exit";
|
||||
invokerUtil.get(serverUrl, function (response) {
|
||||
if (response == "[]") {
|
||||
$(".fence-not-exist").show();
|
||||
$("#exit-alert").hide();
|
||||
}
|
||||
else if (response) {
|
||||
$(".fence-not-exist").hide();
|
||||
$("#exit-alert").show();
|
||||
response = JSON.parse(response);
|
||||
for (var index in response) {
|
||||
var alertBean = response[index];
|
||||
$("#exit-alert > tbody").append(
|
||||
"<tr class='viewGeoFenceRow' style='cursor: pointer' data-areaName='" + alertBean.areaName +
|
||||
"' data-queryName='" + alertBean.queryName + "'data-geoJson="+ alertBean.geoJson +"><td>" + alertBean.areaName + "</td>" +
|
||||
"<td>" + alertBean.queryName + "</td><td>" + formatDate(new Date(alertBean.createdTime)) + "</td>" +
|
||||
"<td onClick=removeGeoFence(this.parentElement,'Exit') class='removeGeoFence'" +
|
||||
" data-toggle='tooltip' title='Remove fence' ><i class='fa fa-trash-o'></i></td></tr>");
|
||||
}
|
||||
} else {
|
||||
$(".fence-not-exist").show();
|
||||
$("#exit-alert").hide();
|
||||
}
|
||||
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
|
||||
viewFence(this.parentElement,'Exit');
|
||||
});
|
||||
});
|
||||
}
|
||||
initializeExit();
|
@ -0,0 +1,580 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var drawControl;
|
||||
var speedGraphControl;
|
||||
var removeAllControl;
|
||||
var drawnItems;
|
||||
var lastId;
|
||||
var controlDiv;
|
||||
var deleteLayers;
|
||||
var deleteLayersCount;
|
||||
|
||||
loadGeoFencing();
|
||||
|
||||
function loadGeoFencing() {
|
||||
if (map == null) {
|
||||
setTimeout(loadGeoFencing, 1000); // give everything some time to render
|
||||
} else {
|
||||
map.on('draw:created', function (e) {
|
||||
var type = e.layerType, layer = e.layer;
|
||||
drawnItems.addLayer(layer);
|
||||
console.log("created layer for "+ lastId);
|
||||
createPopup(layer,lastId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openTools(id) {
|
||||
lastId = id;
|
||||
if (drawControl) {
|
||||
try{
|
||||
map.removeControl(drawControl);
|
||||
} catch(e) {
|
||||
console.log("error: " + e.message);
|
||||
}
|
||||
console.log("removed drawControl");
|
||||
}
|
||||
if (removeAllControl) {
|
||||
try {
|
||||
map.removeControl(removeAllControl);
|
||||
} catch(e) {
|
||||
console.log("error: " + e.message);
|
||||
}
|
||||
console.log("removed removeAllControl");
|
||||
}
|
||||
if (drawnItems) {
|
||||
try{
|
||||
map.removeLayer(drawnItems);
|
||||
console.log("removing layer");
|
||||
} catch(e) {
|
||||
console.log("error: " + e.message);
|
||||
}
|
||||
console.log("removed drawnItems");
|
||||
}
|
||||
|
||||
closeAll();
|
||||
noty({text: "Please draw the required area on the map", type: "information"});
|
||||
|
||||
L.Control.RemoveAll = L.Control.extend(
|
||||
{
|
||||
options: {
|
||||
position: 'topleft'
|
||||
},
|
||||
onAdd: function (map) {
|
||||
controlDiv = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');
|
||||
L.DomEvent
|
||||
.addListener(controlDiv, 'click', L.DomEvent.stopPropagation)
|
||||
.addListener(controlDiv, 'click', L.DomEvent.preventDefault)
|
||||
.addListener(controlDiv, 'click', function () {
|
||||
controlDiv.remove();
|
||||
drawControl.removeFrom(map);
|
||||
drawnItems.clearLayers();
|
||||
if(id == "Prediction"){
|
||||
$('#predictionResults').animate({width: ['toggle','swing']},200);
|
||||
toggeled = false;
|
||||
}
|
||||
});
|
||||
|
||||
var controlUI = L.DomUtil.create('a', 'fa fa-times fa-lg drawControlCloseButton', controlDiv);
|
||||
$(controlUI).css("background-image", "none"); // Remove default control icon
|
||||
// TODO: bad usage of .hover() use CSS instead
|
||||
$(controlUI).mouseenter(function () {
|
||||
$(this).css("color", "red");
|
||||
}).mouseleave(function () {
|
||||
$(this).css("color", "black")
|
||||
});
|
||||
|
||||
controlUI.title = 'Close drawer tools';
|
||||
controlUI.href = '#';
|
||||
return controlDiv;
|
||||
}
|
||||
});
|
||||
removeAllControl = new L.Control.RemoveAll();
|
||||
map.addControl(removeAllControl);
|
||||
|
||||
// Initialise the FeatureGroup to store editable layers
|
||||
drawnItems = new L.FeatureGroup();
|
||||
map.addLayer(drawnItems);
|
||||
|
||||
if (id=="WithIn") {
|
||||
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
||||
drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: {
|
||||
allowIntersection: false, // Restricts shapes to simple polygons
|
||||
drawError: {
|
||||
color: '#002bff', // Color the shape will turn when intersects
|
||||
message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
|
||||
},
|
||||
shapeOptions: {
|
||||
color: '#002bff'
|
||||
}
|
||||
},
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#002bff'
|
||||
}
|
||||
},
|
||||
polyline: false,
|
||||
circle: false, // Turns off this drawing tool
|
||||
marker: false // Markers are not applicable for within geo fencing
|
||||
},
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
}
|
||||
});
|
||||
} else if (id=="Exit") {
|
||||
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
||||
drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: {
|
||||
allowIntersection: false, // Restricts shapes to simple polygons
|
||||
drawError: {
|
||||
color: '#ff0043', // Color the shape will turn when intersects
|
||||
message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
|
||||
},
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
},
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
},
|
||||
polyline: false,
|
||||
circle: false, // Turns off this drawing tool
|
||||
marker: false // Markers are not applicable for within geo fencing
|
||||
},
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
}
|
||||
});
|
||||
} else if(id=="Stationery"){
|
||||
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
||||
drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: {
|
||||
allowIntersection: false, // Restricts shapes to simple polygons
|
||||
drawError: {
|
||||
color: '#e1e100', // Color the shape will turn when intersects
|
||||
message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
|
||||
},
|
||||
shapeOptions: {
|
||||
color: '#e1e100'
|
||||
}
|
||||
},
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#e1e100'
|
||||
}
|
||||
},
|
||||
polyline: false,
|
||||
circle: {
|
||||
shapeOptions: {
|
||||
color: '#e1e100'
|
||||
}
|
||||
},
|
||||
marker: false // Markers are not applicable for within geo fencing
|
||||
},
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
}
|
||||
});
|
||||
} else if (id=="Traffic") {
|
||||
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
||||
drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: {
|
||||
allowIntersection: false, // Restricts shapes to simple polygons
|
||||
drawError: {
|
||||
color: '#e1e100', // Color the shape will turn when intersects
|
||||
message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
|
||||
},
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
},
|
||||
rectangle: {
|
||||
shapeOptions: {
|
||||
color: '#002bff'
|
||||
}
|
||||
},
|
||||
polyline: false,
|
||||
circle: {
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
},
|
||||
marker: {
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
}
|
||||
},
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
}
|
||||
});
|
||||
} else if (id =="Prediction") {
|
||||
drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: false,
|
||||
rectangle: false,
|
||||
polyline: false,
|
||||
circle: false,
|
||||
marker: {
|
||||
shapeOptions: {
|
||||
color: '#ff0043'
|
||||
}
|
||||
}
|
||||
},
|
||||
edit: {
|
||||
featureGroup: drawnItems
|
||||
}
|
||||
});
|
||||
console.log("prediction tool opened");
|
||||
}
|
||||
map.addControl(drawControl);
|
||||
map.on('draw:created', function (e) {
|
||||
var type = e.layerType, layer = e.layer;
|
||||
drawnItems.addLayer(layer);
|
||||
console.log("created layer for "+ lastId);
|
||||
createPopup(layer,lastId);
|
||||
});
|
||||
}
|
||||
|
||||
function createPopup(layer,id) {
|
||||
if (id=="WithIn") {
|
||||
var popupTemplate = $('#setWithinAlert');
|
||||
popupTemplate.find('#addWithinAlert').attr('leaflet_id', layer._leaflet_id);
|
||||
} else if (id=="Exit") {
|
||||
var popupTemplate = $('#setExitAlert');
|
||||
popupTemplate.find('#addExitAlert').attr('leaflet_id', layer._leaflet_id);
|
||||
} else if (id=="Stationery") {
|
||||
var popupTemplate = $('#setStationeryAlert');
|
||||
popupTemplate.find('#addStationeryAlert').attr('leaflet_id', layer._leaflet_id);
|
||||
} else if (id=="Traffic") {
|
||||
var popupTemplate = $('#setTrafficAlert');
|
||||
popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id);
|
||||
//console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id);
|
||||
} else if (id=="Prediction") {
|
||||
getPrediction(layer._leaflet_id);
|
||||
return;
|
||||
}
|
||||
|
||||
popupTemplate.find('.exportGeoJson').attr('leaflet_id', layer._leaflet_id);
|
||||
popupTemplate.find('.editGeoJson').attr('leaflet_id', layer._leaflet_id);
|
||||
|
||||
layer.bindPopup(popupTemplate.html(), {closeOnClick: false, closeButton: false}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(layer._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
}
|
||||
|
||||
function toggleSpeedGraph() {
|
||||
if (speedGraphControl) {
|
||||
try {
|
||||
map.removeControl(speedGraphControl);
|
||||
speedGraphControl = null;
|
||||
} catch (e) {
|
||||
console.log("error: " + e.message);
|
||||
}
|
||||
} else {
|
||||
speedGraphControl = new L.control.speedChart({'position' : 'topright'});
|
||||
map.addControl(speedGraphControl);
|
||||
}
|
||||
}
|
||||
|
||||
function closeTools(leafletId) {
|
||||
map.removeLayer(map._layers[leafletId]);
|
||||
map.removeControl(drawControl);
|
||||
controlDiv.remove();
|
||||
console.log("DEBUG: closeTools(leafletId) = "+leafletId);
|
||||
}
|
||||
|
||||
/* Export selected area on the map as a json encoded geoJson standard file, no back-end calls simple HTML5 trick ;) */
|
||||
function exportToGeoJSON(element, content) {
|
||||
// HTML5 features has been used here
|
||||
var geoJsonData = 'data:application/json;charset=utf-8,' + encodeURIComponent(content);
|
||||
// TODO: replace closest() by using persistence id for templates, template id prefixed by unique id(i.e leaflet_id)
|
||||
var fileName = $(element).closest('form').attr('area-name') || 'geoJson';
|
||||
var link = document.createElement("a");
|
||||
link.download = fileName + '.json'; // Use the fence name given by the user as the file name of the JSON file;
|
||||
link.href = geoJsonData;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
delete link;
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$("#importGeoJsonFile").change(function () {
|
||||
var importedFile = this.files[0];
|
||||
var reader = new FileReader();
|
||||
reader.readAsText(importedFile);
|
||||
reader.onload = function (e) {
|
||||
$("#enterGeoJson").text(e.target.result.toString());
|
||||
};
|
||||
});
|
||||
});
|
||||
function importGeoJson() {
|
||||
var updatedGeoJson;
|
||||
updatedGeoJson = $('#enterGeoJson').val();
|
||||
updateDrawing(updatedGeoJson);
|
||||
}
|
||||
|
||||
function updateDrawing(updatedGeoJson) {
|
||||
updatedGeoJson = JSON.parse(updatedGeoJson);
|
||||
// Pop the last LatLng pair because according to the geoJSON standard it use complete round LatLng set to store polygon coordinates
|
||||
updatedGeoJson.geometry.coordinates[0].pop();
|
||||
var leafletLatLngs = [];
|
||||
$.each(updatedGeoJson.geometry.coordinates[0], function (idx, pItem) {
|
||||
leafletLatLngs.push({lat: pItem[1], lng: pItem[0]});
|
||||
});
|
||||
var polygon = new L.Polygon(leafletLatLngs);
|
||||
polygon.editing.enable();
|
||||
map.addLayer(polygon);
|
||||
createPopup(polygon);
|
||||
closeAll();
|
||||
}
|
||||
|
||||
var prevLayers = [];
|
||||
function clearPrevLayers() {
|
||||
for(var i =0; i < prevLayers.length; i++) {
|
||||
var prevLayer = prevLayers[i];
|
||||
map.removeLayer(prevLayer);
|
||||
}
|
||||
prevLayers.length = 0;
|
||||
}
|
||||
|
||||
function viewFence(geoFenceElement,id) {
|
||||
if (deleteLayers && !deleteLayersCount) {
|
||||
clearPrevLayers();
|
||||
deleteLayersCount = true;
|
||||
deleteLayers = false;
|
||||
}
|
||||
var geoJson = $(geoFenceElement).attr('data-geoJson');
|
||||
var matchResults = /(?:"geoFenceGeoJSON"):"{(.*)}"/g.exec(geoJson);
|
||||
if (matchResults && matchResults.length > 1) {
|
||||
geoJson = "{" + matchResults[1] + "}";
|
||||
}
|
||||
geoJson = JSON.parse(geoJson.replace(/'/g, '"'));
|
||||
var queryName = $(geoFenceElement).attr('data-queryName');
|
||||
var areaName = $(geoFenceElement).attr('data-areaName');
|
||||
var geometryShape;
|
||||
var circleOptions = {color: null};
|
||||
var polygonOptions = {color: null};
|
||||
|
||||
if (id == "Exit") {
|
||||
circleOptions.color = '#ff0043';
|
||||
polygonOptions.color = '#ff0043';
|
||||
} else if (id == "WithIn") {
|
||||
circleOptions.color = '#002bff';
|
||||
polygonOptions.color = '#002bff';
|
||||
} else {
|
||||
circleOptions.color = '#e1e100';
|
||||
polygonOptions.color = '#e1e100';
|
||||
}
|
||||
|
||||
if (geoJson.type=="Point") {
|
||||
geometryShape= new L.circle([geoJson.coordinates[1],geoJson.coordinates[0]], geoJson.radius,circleOptions);
|
||||
map.addLayer(geometryShape);
|
||||
prevLayers.push(geometryShape);
|
||||
} else if (geoJson.type=="Polygon") {
|
||||
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
||||
var leafletLatLngs = [];
|
||||
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
||||
leafletLatLngs.push({lat: pItem[1], lng: pItem[0]});
|
||||
});
|
||||
geometryShape = new L.Polygon(leafletLatLngs,polygonOptions);
|
||||
map.addLayer(geometryShape);
|
||||
prevLayers.push(geometryShape);
|
||||
}
|
||||
|
||||
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
||||
|
||||
if (id=="Stationery") {
|
||||
|
||||
var stationeryTime=$(geoFenceElement).attr('data-stationeryTime');
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewStationeryAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaName').html(areaName);
|
||||
popupTemplate.find('#stationaryAlertForm').attr('area-name', areaName);
|
||||
popupTemplate.find('#stationaryAlertForm').attr('query-name', queryName);
|
||||
popupTemplate.find('#viewAreaTime').html(stationeryTime);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
|
||||
});
|
||||
} else if (id=="WithIn") {
|
||||
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaName').html(areaName);
|
||||
popupTemplate.find('#withinAlertForm').attr('area-name', areaName);
|
||||
popupTemplate.find('#withinAlertForm').attr('query-name', queryName);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
});
|
||||
} else if (id=="Exit") {
|
||||
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaName').html(areaName);
|
||||
popupTemplate.find('#exitAlertForm').attr('area-name', areaName);
|
||||
popupTemplate.find('#exitAlertForm').attr('query-name', queryName);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
});
|
||||
}
|
||||
closeAll();
|
||||
}
|
||||
|
||||
// view all defined fence areas of a particular alert type
|
||||
function viewAll(id) {
|
||||
deleteLayers = true;
|
||||
deleteLayersCount = false;
|
||||
|
||||
var table = null;
|
||||
if (id == "Exit") {
|
||||
table = $("#exit-alert > tbody");
|
||||
} else if (id == "WithIn") {
|
||||
table = $("#within-alert > tbody");
|
||||
} else {
|
||||
table = $("#stationary-alert-table > tbody");
|
||||
}
|
||||
|
||||
table.find('tr').each(function (i, el) {
|
||||
viewFence(this,id);
|
||||
});
|
||||
}
|
||||
|
||||
// View all defined fence areas of all alert types
|
||||
function viewAllFences() {
|
||||
deleteLayers = true;
|
||||
deleteLayersCount = false;
|
||||
initializeExit();
|
||||
initializeWithin();
|
||||
initStationaryAlert();
|
||||
initializeSpeed();
|
||||
|
||||
var table = $("#exit-alert > tbody");
|
||||
table.find('tr').each(function (i, el) {
|
||||
viewFence(this,'Exit');
|
||||
});
|
||||
table = $("#within-alert > tbody");
|
||||
table.find('tr').each(function (i, el) {
|
||||
viewFence(this,'WithIn');
|
||||
});
|
||||
table = $("#stationary-alert-table > tbody");
|
||||
table.find('tr').each(function (i, el) {
|
||||
viewFence(this,'Stationery');
|
||||
});
|
||||
}
|
||||
|
||||
function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
||||
var matchResults = /(?:"geoFenceGeoJSON"):"{(.*)}"/g.exec(geoJson);
|
||||
if (matchResults && matchResults.length > 1) {
|
||||
geoJson = "{" + matchResults[1] + "}";
|
||||
}
|
||||
geoJson = JSON.parse(geoJson.replace(/'/g, '"'));
|
||||
var geometryShape;
|
||||
|
||||
var circleOptions = {color: null};
|
||||
var polygonOptions = {color: null};
|
||||
|
||||
if (id == "Exit") {
|
||||
circleOptions.color = '#ff0043';
|
||||
polygonOptions.color = '#ff0043';
|
||||
} else if (id == "WithIn") {
|
||||
circleOptions.color = '#002bff';
|
||||
polygonOptions.color = '#002bff';
|
||||
} else {
|
||||
circleOptions.color = '#e1e100';
|
||||
polygonOptions.color = '#e1e100';
|
||||
}
|
||||
|
||||
if (geoJson.type=="Point") {
|
||||
|
||||
geometryShape= new L.circle([geoJson.coordinates[1],geoJson.coordinates[0]], geoJson.radius,circleOptions);
|
||||
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
|
||||
map.addLayer(geometryShape);
|
||||
// map.addLayer(marker);
|
||||
} else if (geoJson.type=="Polygon") {
|
||||
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
||||
var leafletLatLngs = [];
|
||||
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
||||
leafletLatLngs.push({lat: pItem[1], lng: pItem[0]});
|
||||
});
|
||||
geometryShape = new L.Polygon(leafletLatLngs,polygonOptions);
|
||||
map.addLayer(geometryShape);
|
||||
}
|
||||
|
||||
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
||||
|
||||
if (id=="Stationery") {
|
||||
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewStationeryAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaTime').html(stationeryTime);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
|
||||
});
|
||||
} else if (id=="WithIn") {
|
||||
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaName').html(areaName);
|
||||
popupTemplate.find('#withinAlertForm').attr('area-name', areaName);
|
||||
popupTemplate.find('#withinAlertForm').attr('query-name', queryName);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
});
|
||||
} else if (id=="Exit") {
|
||||
|
||||
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
||||
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
||||
popupTemplate.find('#exportGeoJson').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#hideViewFence').attr('leaflet_id', geometryShape._leaflet_id);
|
||||
popupTemplate.find('#viewAreaName').html(areaName);
|
||||
popupTemplate.find('#exitAlertForm').attr('area-name', areaName);
|
||||
popupTemplate.find('#exitAlertForm').attr('query-name', queryName);
|
||||
geometryShape.bindPopup(popupTemplate.html(), {closeButton: true}).openPopup();
|
||||
// transparent the layer .leaflet-popup-content-wrapper
|
||||
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
||||
});
|
||||
}
|
||||
closeAll();
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var centerLocation = new L.LatLng(6.999833130825296, 79.99855044297874);
|
||||
var resizeIconLocation = new L.LatLng(6.99847, 80.14412);
|
||||
var proximityMap = L.map("proximityMap", {
|
||||
zoom: 10,
|
||||
center: centerLocation,
|
||||
zoomControl: false,
|
||||
attributionControl: false,
|
||||
maxZoom: 20
|
||||
});
|
||||
var proximityDistance = $("#proximityDistance");
|
||||
//TODO invoker-util
|
||||
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Proximity";
|
||||
// var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts.jag?executionPlanType=Proximity&deviceId=" + deviceId;
|
||||
invokerUtil.get(serverUrl, function (response) {
|
||||
response = JSON.parse(response);
|
||||
proximityDistance.val(response.proximityDistance);
|
||||
$("#proximityTime").val(response.proximityTime);
|
||||
});
|
||||
|
||||
L.grid({
|
||||
redraw: 'move'
|
||||
}).addTo(proximityMap);
|
||||
|
||||
proximityMap.scrollWheelZoom.disable();
|
||||
|
||||
var marker = L.marker(centerLocation).setIcon(normalMovingIcon);
|
||||
|
||||
marker.addTo(proximityMap);
|
||||
|
||||
var resizeIcon = L.icon({
|
||||
iconUrl: ApplicationOptions.leaflet.iconUrls.resizeIcon,
|
||||
iconAnchor: [24, 24]
|
||||
});
|
||||
|
||||
var resizeMarker = L.marker(resizeIconLocation, {icon: resizeIcon, draggable: 'true'}).addTo(proximityMap);
|
||||
resizeMarker.on('drag', updateRuler);
|
||||
|
||||
var measureLine = new L.Polyline(
|
||||
[centerLocation, resizeIconLocation ],
|
||||
{ color: "black", opacity: 0.5, stroke: true });
|
||||
|
||||
|
||||
proximityMap.addLayer(measureLine);
|
||||
measureLine._path.setAttribute("class", 'measuring-line-for-look');
|
||||
|
||||
var options = {
|
||||
minWidth: 50,
|
||||
autoPan: false,
|
||||
closeButton: true, // should the popups have a close option?
|
||||
displayTotalDistance: true,
|
||||
displayPartialDistance: false,
|
||||
className: 'measuring-label-tooltip' /*css label class name*/
|
||||
};
|
||||
// var totalDistancePopup = new L.Popup(options,measureLine);
|
||||
var initialDistance = centerLocation.distanceTo(resizeIconLocation);
|
||||
|
||||
var measureCircle = L.circle(centerLocation, initialDistance).addTo(proximityMap);
|
||||
|
||||
function updateRuler(e) {
|
||||
var target = e.target;
|
||||
resizeIconLocation = target.getLatLng();
|
||||
measureLine.setLatLngs([centerLocation, resizeIconLocation]);
|
||||
setDistancePopup(centerLocation, resizeIconLocation)
|
||||
}
|
||||
|
||||
function setDistancePopup(startLatLng, endLatLng) {
|
||||
var centerPos = new L.LatLng((startLatLng.lat + endLatLng.lat) / 2,
|
||||
(startLatLng.lng + endLatLng.lng) / 2),
|
||||
distance = startLatLng.distanceTo(endLatLng);
|
||||
proximityDistance.val(distance.toFixed(2));
|
||||
measureCircle.setRadius(distance);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function initializeSpeed() {
|
||||
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Speed";
|
||||
// var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts.jag?executionPlanType=Speed&deviceId=" + deviceId;
|
||||
invokerUtil.get(serverUrl, function (response) {
|
||||
response = JSON.parse(response);
|
||||
if (response) {
|
||||
$("#speedAlertValue").val(response.speedLimit);
|
||||
}
|
||||
});
|
||||
}
|
||||
initializeSpeed();
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function initStationaryAlert() {
|
||||
// var serverUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts.jag?executionPlanType=Stationery&deviceId=" + deviceId;
|
||||
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Stationery";
|
||||
|
||||
$(".removeGeoFence").tooltip();
|
||||
$("#stationary-alert-table > tbody").empty();
|
||||
invokerUtil.get(serverUrl, function (response) {
|
||||
if (response == "[]") {
|
||||
$(".fence-not-exist").show();
|
||||
$("#stationary-alert-table").hide();
|
||||
}
|
||||
else if (response) {
|
||||
response = JSON.parse(response);
|
||||
$(".fence-not-exist").hide();
|
||||
$("#stationary-alert-table").show();
|
||||
for (var index in response) {
|
||||
var alert = response[index];
|
||||
$("#stationary-alert-table > tbody").append(
|
||||
"<tr class='viewGeoFenceRow'style='cursor: pointer' data-stationeryTime='" + alert.stationaryTime +
|
||||
"'data-fluctuationRadius='" + alert.fluctuationRadius + "'data-areaName='" + alert.areaName +
|
||||
"'data-queryName='" + alert.queryName + "'data-geoJson=" + alert.geoJson + ">" +
|
||||
"<td>" + alert.areaName + "</td><td>" + alert.stationaryTime + "</td><td>" + alert.fluctuationRadius +
|
||||
"<td>" + alert.queryName + "</td><td>" + formatDate(new Date(alert.createdTime)) + "</td><td" +
|
||||
" onClick=removeGeoFence(this.parentElement,'Stationery') data-toggle=" +
|
||||
" 'tooltip' title='Remove fence' ><i class='fa fa-trash-o'></i></td></tr>")
|
||||
}
|
||||
} else{
|
||||
$(".fence-not-exist").show();
|
||||
$("#stationary-alert-table").hide();
|
||||
}
|
||||
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
|
||||
viewFence(this.parentElement,'Stationery');
|
||||
});
|
||||
});
|
||||
}
|
||||
initStationaryAlert();
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function initializeWithin() {
|
||||
$(".removeGeoFence").tooltip();
|
||||
$("#within-alert > tbody").empty();
|
||||
var serverUrl = "/api/device-mgt/v1.0/geo-services/alerts/Within";
|
||||
invokerUtil.get(serverUrl, function (response) {
|
||||
if (response == "[]") {
|
||||
$(".fence-not-exist").show();
|
||||
$("#within-alert").hide();
|
||||
}
|
||||
else if (response) {
|
||||
$(".fence-not-exist").hide();
|
||||
$("#within-alert").show();
|
||||
response = JSON.parse(response);
|
||||
for (var index in response) {
|
||||
var alertBean = response[index];
|
||||
$("#within-alert > tbody").append(
|
||||
"<tr class='viewGeoFenceRow' style='cursor: pointer' data-areaName='" + alertBean.areaName +
|
||||
"' data-queryName='" + alertBean.queryName + "'data-geoJson="+ alertBean.geoJson +"><td>" + alertBean.areaName + "</td>" +
|
||||
"<td>" + alertBean.queryName + "</td><td>" + formatDate(new Date(alertBean.createdTime)) + "</td>" +
|
||||
"<td onClick=removeGeoFence(this.parentElement,'Within') class='removeGeoFence'" +
|
||||
" data-toggle='tooltip' title='Remove fence' ><i class='fa fa-trash-o'></i></td></tr>");
|
||||
}
|
||||
} else{
|
||||
$(".fence-not-exist").show();
|
||||
$("#within-alert").hide();
|
||||
}
|
||||
$('.viewGeoFenceRow td:not(:last-child)').click(function () {
|
||||
viewFence(this.parentElement,'WithIn');
|
||||
});
|
||||
});
|
||||
}
|
||||
initializeWithin();
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,10 @@
|
||||
|
||||
function reformatRadius(val){
|
||||
if(val != "" && !isNaN(val)){
|
||||
$("#fRadius" ).val(parseFloat(Math.round(val * 100) / 100).toFixed(2));
|
||||
} else{
|
||||
var message = "Invalid Fluctuation Radius Provided.";
|
||||
noty({text: message, type: 'error'});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function showAlertInMap(alertData) {
|
||||
clearFocus();
|
||||
var id = $(alertData).attr("data-id");
|
||||
var latitude = $(alertData).attr("data-latitude");
|
||||
var longitude = $(alertData).attr("data-longitude");
|
||||
var state = $(alertData).attr("data-state");
|
||||
var information = $(alertData).attr("data-information");
|
||||
|
||||
console.log(information);
|
||||
|
||||
var alertLatLngPoint = L.latLng(latitude,longitude);
|
||||
|
||||
var alertOccouredArea = L.circle(alertLatLngPoint, 10, {
|
||||
color: '#FF9900',
|
||||
fillColor: '#FF00FF',
|
||||
fillOpacity: 0.5
|
||||
}).addTo(map);
|
||||
|
||||
alertOccouredArea.bindPopup("Id: <b>"+id+"</b><br>"+
|
||||
"State: <b>"+state+"</b><br>"+
|
||||
"Information: <b>"+information+"</b><br>"
|
||||
).openPopup();
|
||||
$(alertOccouredArea._popup._closeButton).on("click",function(){map.removeLayer(alertOccouredArea)});
|
||||
map.setView(alertLatLngPoint,18);
|
||||
|
||||
/* TODO: for reference <Update lib or remove if not in use>: This `R`(RaphaelLayer: https://github.com/dynmeth/RaphaelLayer) library is dam buggy can't use it reliably */
|
||||
/*
|
||||
var alertPulse = new R.Pulse(
|
||||
alertLatLngPoint,
|
||||
8,
|
||||
{'stroke': '#FF9E0E', 'fill': '#FF0000'},
|
||||
{'stroke': '#FF3E2F', 'stroke-width': 3});
|
||||
map.addLayer(alertPulse);
|
||||
*/
|
||||
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,355 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var debugObject; // assign object and debug from browser console, this is for debugging purpose , unless this var is unused
|
||||
var showPathFlag = false; // Flag to hold the status of draw objects path
|
||||
var currentSpatialObjects = {};
|
||||
var selectedSpatialObject; // This is set when user search for an object from the search box
|
||||
var spatialWebsocket;
|
||||
var onAlertWebsocket;
|
||||
var onTrafficStreamWebsocket;
|
||||
var currentPredictions = {};
|
||||
// Make the function wait until the connection is made...
|
||||
var waitTime = 1000;
|
||||
var webSocketURL, alertWebSocketURL, trafficStreamWebSocketURL;
|
||||
var deviceId;
|
||||
var deviceType;
|
||||
var isBatchModeOn = false;
|
||||
var wsToken;
|
||||
var geoPublicUri;
|
||||
|
||||
function processPointMessage(geoJsonFeature) {
|
||||
if (geoJsonFeature.id in currentSpatialObjects) {
|
||||
var excitingObject = currentSpatialObjects[geoJsonFeature.id];
|
||||
excitingObject.update(geoJsonFeature);
|
||||
}
|
||||
else {
|
||||
var receivedObject = new SpatialObject(geoJsonFeature);
|
||||
receivedObject.update(geoJsonFeature);
|
||||
currentSpatialObjects[receivedObject.id] = receivedObject;
|
||||
currentSpatialObjects[receivedObject.id].addTo(map);
|
||||
}
|
||||
}
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
disconnect();
|
||||
};
|
||||
|
||||
function initializeSpatialStreamWebSocket() {
|
||||
spatialWebsocket = new WebSocket(webSocketURL);
|
||||
spatialWebsocket.onopen = webSocketSpatialOnOpen;
|
||||
spatialWebsocket.onmessage = webSocketSpatialOnMessage;
|
||||
spatialWebsocket.onclose = webSocketSpatialOnClose;
|
||||
spatialWebsocket.onerror = webSocketSpatialOnError;
|
||||
}
|
||||
|
||||
function initializeOnAlertWebSocket() {
|
||||
onAlertWebsocket = new WebSocket(alertWebSocketURL);
|
||||
onAlertWebsocket.onmessage = webSocketOnAlertMessage;
|
||||
onAlertWebsocket.onclose = webSocketOnAlertClose;
|
||||
onAlertWebsocket.onerror = webSocketOnAlertError;
|
||||
onAlertWebsocket.onopen = webSocketOnAlertOpen;
|
||||
}
|
||||
|
||||
function initializeGeoLocation(geoFencingEnabled) {
|
||||
if (true) {
|
||||
var geoCharts = $("#geo-charts");
|
||||
var wsEndPoint = geoCharts.data("ws-endpoint");
|
||||
wsToken = geoCharts.data("ws-token");
|
||||
geoPublicUri = geoCharts.data("geo-public-uri");
|
||||
geoPublicUri = geoCharts.data("geo-public-uri");
|
||||
webSocketURL = wsEndPoint + "iot.per.device.stream.geo.FusedSpatialEvent/1.0.0?" + "&websocketToken=" + wsToken;
|
||||
alertWebSocketURL = wsEndPoint + "iot.per.device.stream.geo.AlertsNotifications/1.0.0?" + "&websocketToken=" + wsToken;
|
||||
$("#proximity_alert").hide();
|
||||
|
||||
if (geoFencingEnabled) {
|
||||
disconnect();
|
||||
initializeSpatialStreamWebSocket();
|
||||
initializeOnAlertWebSocket();
|
||||
}
|
||||
initialLoad(geoFencingEnabled);
|
||||
} else {
|
||||
noty({text: 'Invalid Access! No device information provided to track!', type: 'error'});
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect(){
|
||||
if (spatialWebsocket && spatialWebsocket.readyState == spatialWebsocket.OPEN){
|
||||
spatialWebsocket.close();
|
||||
}
|
||||
|
||||
if (onAlertWebsocket && onAlertWebsocket.readyState == onAlertWebsocket.OPEN){
|
||||
onAlertWebsocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function popupDateRange() {
|
||||
$('#dateRangePopup').attr('title', 'Device ID - ' + deviceId + " Device Type - " + deviceType).dialog();
|
||||
}
|
||||
|
||||
var headings = ["North", "NorthEast", "East", "SouthEast", "South", "SouthWest", "West", "NorthWest"];
|
||||
|
||||
function angleToHeading(angle) {
|
||||
var angle = (angle + 360 + 22.5 ) % 360;
|
||||
angle = Math.floor(angle / 45);
|
||||
return headings[angle];
|
||||
}
|
||||
|
||||
|
||||
function processTrafficMessage(json) {
|
||||
|
||||
if (json.id in currentSpatialObjects) {
|
||||
var existingObject = currentSpatialObjects[json.id];
|
||||
existingObject.update(json);
|
||||
}
|
||||
else {
|
||||
var receivedObject = new GeoAreaObject(json);
|
||||
currentSpatialObjects[json.id] = receivedObject;
|
||||
currentSpatialObjects[json.id].addTo(map);
|
||||
}
|
||||
}
|
||||
|
||||
function processAlertMessage(json) {
|
||||
if (json.state != "NORMAL" && json.state != "MINIMAL") {
|
||||
notifyAlert("Object ID: <span style='color: blue;cursor: pointer' onclick='focusOnSpatialObject(" + json.id + ")'>" + json.id + "</span> change state to: <span style='color: red'>" + json.state + "</span> Info : " + json.information);
|
||||
}
|
||||
}
|
||||
|
||||
/*function setPropertySafe(obj)
|
||||
{
|
||||
function isObject(o)
|
||||
{
|
||||
if (o === null) return false;
|
||||
var type = typeof o;
|
||||
return type === 'object' || type === 'function';
|
||||
}
|
||||
if (!isObject(obj)) return;
|
||||
var prop;
|
||||
for (var i=1; i < arguments.length-1; i++)
|
||||
{
|
||||
prop = arguments[i];
|
||||
if (!isObject(obj[prop])) obj[prop] = {};
|
||||
if (i < arguments.length-2) obj = obj[prop];
|
||||
}
|
||||
obj[prop] = arguments[i];
|
||||
}*/
|
||||
|
||||
function processPredictionMessage(json) {
|
||||
setPropertySafe(currentPredictions, json.day, json.hour, json.longitude, json.latitude, json.traffic - 1);
|
||||
}
|
||||
|
||||
WebSocket.prototype.set_opened = function () {
|
||||
this._opened = true;
|
||||
};
|
||||
|
||||
WebSocket.prototype.get_opened = function () {
|
||||
return this._opened || false;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
var _longitudeStart = -0.0925
|
||||
var _latitudeStart = 51.4985
|
||||
var _unit = 0.005;
|
||||
function requestPredictions(longitude, latitude, d) {
|
||||
var serverUrl = "http://localhost:9763/endpoints/GpsDataOverHttp/predictionInput";
|
||||
function loop(i) {
|
||||
setTimeout(function() {
|
||||
var data = {
|
||||
day : d.getUTCDate() - 3,
|
||||
hour : d.getUTCHours() + i + 1,
|
||||
latitude : Math.round((latitude - _latitudeStart)/_unit),
|
||||
longitude : Math.round((longitude - _longitudeStart)/_unit)
|
||||
};
|
||||
var json = JSON.stringify(data);
|
||||
$.ajax({
|
||||
url: serverUrl,
|
||||
type: "POST",
|
||||
data: json,
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
});
|
||||
if(i<6) {
|
||||
loop(i+1);
|
||||
}
|
||||
},500);
|
||||
}
|
||||
loop(0);
|
||||
}
|
||||
var d= new Date();
|
||||
//requestPredictions(-0.09,51.5,d);
|
||||
function getPredictions(longitude, latitude, d) {
|
||||
var longitude = Math.round((longitude - _longitudeStart)/_unit);
|
||||
var latitude = Math.round((latitude - _latitudeStart)/_unit);
|
||||
var traffic = [['x',0,0,0,0,0,0],['data',0,0,0,0,0,0]];
|
||||
var hour = d.getUTCHours();
|
||||
var day = d.getUTCDate() - 3;
|
||||
for (var i = 0; i < 6; i++) {
|
||||
hour = hour + 1;
|
||||
if (hour > 23) {
|
||||
hour = hour - 24;
|
||||
day = day + 1;
|
||||
}
|
||||
try{
|
||||
traffic[0][i+1] = hour;
|
||||
traffic[1][i+1] = currentPredictions[day][hour][longitude][latitude];
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
return traffic;
|
||||
}*/
|
||||
|
||||
function GeoAreaObject(json) {
|
||||
this.id = json.id;
|
||||
this.type = "area";
|
||||
|
||||
var myStyle = {
|
||||
"color": "#000001",
|
||||
"weight": 5,
|
||||
"opacity": 0,
|
||||
"fillOpacity": 0.75
|
||||
};
|
||||
|
||||
switch (json.properties.state) {
|
||||
case "Moderate":
|
||||
myStyle["color"] = "#ffb13b";
|
||||
break;
|
||||
case "Severe":
|
||||
myStyle["color"] = "#ff3f3f";
|
||||
break;
|
||||
case "Minimal":
|
||||
return null;
|
||||
}
|
||||
|
||||
this.geoJson = L.geoJson(json, {style: myStyle});
|
||||
this.marker = this.geoJson.getLayers()[0];
|
||||
this.marker.options.title = this.id;
|
||||
this.popupTemplate = $('#areaPopup');
|
||||
this.popupTemplate.find('#objectId').html(this.id);
|
||||
this.popupTemplate.find('#severity').html(json.properties.state);
|
||||
this.popupTemplate.find('#information').html(json.properties.information);
|
||||
this.marker.bindPopup(this.popupTemplate.html());
|
||||
return this;
|
||||
}
|
||||
|
||||
GeoAreaObject.prototype.addTo = function (map) {
|
||||
this.geoJson.addTo(map);
|
||||
};
|
||||
|
||||
GeoAreaObject.prototype.focusOn = function (map) {
|
||||
map.fitBounds(this.geoJson);
|
||||
};
|
||||
|
||||
GeoAreaObject.prototype.removeFromMap = function () {
|
||||
map.removeLayer(this.geoJson);
|
||||
};
|
||||
|
||||
GeoAreaObject.prototype.update = function (geoJSON) {
|
||||
|
||||
this.information = geoJSON.properties.information;
|
||||
this.type = geoJSON.properties.type;
|
||||
|
||||
// Update the spatial object leaflet marker
|
||||
this.marker.setLatLng([this.latitude, this.longitude]);
|
||||
this.marker.setIconAngle(this.heading);
|
||||
this.marker.setIcon(this.stateIcon());
|
||||
|
||||
// TODO: use general popup DOM
|
||||
this.popupTemplate.find('#objectId').html(this.id);
|
||||
this.popupTemplate.find('#information').html(this.information);
|
||||
|
||||
this.marker.setPopupContent(this.popupTemplate.html())
|
||||
};
|
||||
|
||||
function notifyAlert(message) {
|
||||
noty({text: "Alert: " + message, type: 'warning'});
|
||||
}
|
||||
|
||||
function Alert(type, message, level) {
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
if (level)
|
||||
this.level = level;
|
||||
else
|
||||
this.level = 'information';
|
||||
|
||||
this.notify = function () {
|
||||
noty({text: this.type + ' ' + this.message, type: level});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var initLoading = true;
|
||||
|
||||
var webSocketOnAlertOpen = function () {
|
||||
$('#ws-alert-stream').removeClass('text-muted text-danger text-success').addClass('text-success');
|
||||
};
|
||||
|
||||
var webSocketOnAlertMessage = function processMessage(message) {
|
||||
if (!isBatchModeOn) {
|
||||
var json = $.parseJSON(message.data);
|
||||
if (json.messageType == "Alert") {
|
||||
processAlertMessage(json);
|
||||
}else {
|
||||
console.log("Message type not supported.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var webSocketOnAlertClose = function (e) {
|
||||
};
|
||||
|
||||
var webSocketOnAlertError = function (e) {
|
||||
var wsURL = alertWebSocketURL;
|
||||
wsURL = wsURL.replace("wss://","https://");
|
||||
var uriParts = wsURL.split("/");
|
||||
wsURL = uriParts[0] + "//" + uriParts[2];
|
||||
noty({text: 'Something went wrong when trying to connect to <b>' + wsURL + '<b/>', type: 'error'});
|
||||
};
|
||||
|
||||
var webSocketSpatialOnOpen = function () {
|
||||
if (initLoading) {
|
||||
initLoading = false;
|
||||
}
|
||||
$('#ws-spatial-stream').removeClass('text-muted text-danger text-success').addClass('text-success');
|
||||
};
|
||||
|
||||
var webSocketSpatialOnMessage = function (message) {
|
||||
if (!isBatchModeOn) {
|
||||
var json = $.parseJSON(message.data);
|
||||
if (json.messageType == "Point") {
|
||||
processPointMessage(json);
|
||||
} else if (json.messageType == "Prediction") {
|
||||
//processPredictionMessage(json);
|
||||
} else {
|
||||
console.log("Message type not supported.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var webSocketSpatialOnClose = function (e) {
|
||||
};
|
||||
|
||||
var webSocketSpatialOnError = function (err) {
|
||||
var wsURL = webSocketURL;
|
||||
wsURL = wsURL.replace("wss://","https://");
|
||||
var uriParts = wsURL.split("/");
|
||||
wsURL = uriParts[0] + "//" + uriParts[2];
|
||||
noty({text: 'Something went wrong when trying to connect to <b>' + wsURL + '<b/>', type: 'error'});
|
||||
};
|
Loading…
Reference in new issue