210 likes | 397 Views
Processing Data. Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador. Outline. Mobile Device-side Processing Server-side Processing. Mobile Device-side Processing. The Critical Point Algorithm.
E N D
Processing Data Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador
Outline • Mobile Device-side Processing • Server-side Processing
Mobile Device-side Processing • The Critical Point Algorithm
Distance-Based Critical Point Algorithm (DB-CPA) • First fix is marked as critical and sent to server • Distance from every valid coordinate to the last critical point is calculated • If the distance is greater than some distance threshold, then the last valid coordinate is marked as critical and sent to the server • If the distance is less than the threshold then the algorithm compares the Horizontal Dilution of Precision (HDOP) values of the last critical point and the last valid point • A lower HDOP value means better precision, therefore, if the last valid coordinate has a lower HDOP than the last critical, then the last valid coordinate is marked as critical point • If neither of the two conditions described above marks the last valid coordinate as critical, then the elapsed time from the last critical point to this last valid coordinate is calculated. If the elapsed time is greater than a time threshold, then the last valid coordinate is marked as critical
Distance-Based Critical Point Algorithm (DB-CPA) • The thresholds play an important role in the algorithm • If the distance threshold is set too high, then many details of the path traversed by a field client will not be sent to the server • If the distance threshold is set too low, then many coordinates will be sent, incrementing the network and server processing overhead • In our current implementation, the distance threshold is set to 20 meters • This means that the field client will send a location update every second only if it is moving at a rate faster than 20 m/s (72 Km/h) • Also in our current implementation, we have kept the time threshold to 30 seconds • These two values can be easily changed to any other value that will make better sense and provide better performance to the system according to the tracking application.
Server-side Processing • Many possibilities, as server has current and historical data • Entire picture of the application and users • Path prediction algorithm based on current data and past behavior • Finding friends, restaurants, etc. • Geo-fencing • Geo-sensing • Geo-advertisement based on user profile • Situational awareness • Traffic alert and emergency notifications • Etc.
Situational Awareness • Wireless sensor network with intrusion detection capabilities integrated into the LBIS • Upon an intrusion detection, the WSN takes a picture and sends a message to the LBIS server • The LBIS server notifies the control station sending a message that also includes the picture • The LBIS server checks if there is any users within a radius of 100 meters from the WSN, and if so, it sends a message with picture to each of those users • Needs to track each user and calculate distances from each user to the location of the WSN
Calculating the Distance Between Two Users • In order to send notifications, the server needs to calculate the distance between the WSN and the individual active users • If distance is less than threshold (100 meters), then server sends a notification message to the user • Otherwise, the user is not notified • PostGIS has functions that make those calculations for you • ST_distance_spherereturns minimum distance in meters between two lon/lat geometries • This function currently does not look at the SRID of a geometry and will always assume its in WGS 84
Calculating Closest Distance to a Point double distance = Double.MAX_VALUE; TrackingUpdatetheClosestOne = new TrackingUpdate(); try { try{ javax.naming.InitialContextic = new javax.naming.InitialContext(); javax.sql.DataSourcedataSource = (javax.sql.DataSource)ic.lookup("jdbc/lbsbook"); Connection theConnection = dataSource.getConnection(); double latitude = Double.parseDouble(request.getParameter("lat")); double longitude = Double.parseDouble(request.getParameter("lng")); PreparedStatementqueryStatement = theConnection.prepareStatement("select fieldsession.sessionid as sesid, fielduser.username as uname, ST_AsText(tracking.position) as pos, ST_distance_sphere(tracking.position, ST_GeomFromText('POINT(? ?)', 32661)) as distance"+“ from fieldsession, tracking,fielduser, select max(idtracking) as idtrack"+"from fieldsession, tracking"+"where fieldsession.datestop is NULL and fieldsession.sessionid = tracking.sessionid“+"group by fieldsession.sessionid) as s2“+"where fieldsession.datestop is NULL and“+"fieldsession.sessionid = tracking.sessionid and“+"tracking.idtracking = s2.idtrack and“+"fieldsession.iduser = fielduser.iduser”);
Calculating ClosestDistance to a Point queryStatement.setDouble(1, longitude); queryStatement.setDouble(2, latitude); ResultSetrs = queryStatement.executeQuery(); double d_temp = 0.0; while(rs.next()) { d_temp = rs.getDouble("distance"); if(d_temp < distance) { theClosestOne.setSessionid(rs.getInt("sesid")); theClosestOne.setUsername(rs.getString("uname")); Point theNewPoint = new Point(rs.getString("pos")); theClosestOne.setLongitude(theNewPoint.getX()); theClosestOne.setLatitude(theNewPoint.getY()); distance = d_temp; } } String theReturnString = "<"; theReturnString = theReturnString + ";“ +theClosestOne.getUsername()+";"+theClosestOne.getsessionId()+";“ +theClosestOne.getLongitude()+";"+theClosestOne.getLatitude()+">"; out.write(theReturnString); }
Calculating Closest Distance to a Point catch (NamingException ex){ Logger.getLogger(DevicerServiceManagerImpl.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex){ Logger.getLogger(DevicerServiceManagerImpl.class.getName()).log(Level.SEVERE, null, ex); } } finally { out.close(); }