CISC 7512X HW# 3: Imagine you have a database table with columns: phoneid, time, gps_latitude, gps_longitude. Assume these records are logged approximately every few seconds for every phone. Your task is to detect speeding: Write a database query (in SQL) to find anyone whose *average* speed is between 90 and 200mph for at least a minute. If can't write SQL query, write detailed procedural speudo code (assume input is coming from a comma delimited text file). Submit code via email, with subject "CISC 7512X HW3".
*/
import java.sql.*;
import java.util.*;

class Main{
private final static String DB_TABLE_NAME = "table1";
private final static String DB_PASSWORD = "";
private final static String DB_USERNAME = "";
private final static String DB_URL = "";
private static final String DELIMITER = ";";
public static void main(String[] args){
StringBuilder statement = new StringBuilder();
Scanner s = new Scanner(System.in);
System.out.println("Enter the start point latitude and longitude separated by space");
double startLat = s.nextDouble();
double startLon = s.nextDouble();
System.out.println("Enter the end point latitude and longitude separated by space");
double endLat = s.nextDouble();
double endLon = s.nextDouble();
s.close();
statement.append("DECLARE @startPoint geography = 'POINT("+startLat+" "+startLon+")';");
statement.append("DECLARE @endPoint geography = 'POINT("+endLat+" "+endLon+")';");
statement.append("SELECT @startPoint.STDistance(@endPoint);");
Statement currentSt = null;
}
}

Comments

Popular posts from this blog