summaryrefslogtreecommitdiffstats
path: root/GSMMapping.java
blob: d644b2e4e0a03d4d6989f49fb3b466e1b768dac9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;

import DataStructure.GSMMap;
import DataStructure.GoogleOut;
import Parse.NMEAParse;
import Parse.sqlreader;

public class GSMMapping {
	// private double[] CoordsNS;
	// private double[] CoordsEW;
	// private double[][] bla;

	// Constructor
	public GSMMapping() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param args
	 * @throws ClassNotFoundException
	 * @throws SQLException
	 * @throws IOException
	 * @throws ParseException
	 */
	public static void main(String[] args) throws SQLException,
			ClassNotFoundException, IOException, ParseException {
		String file = null;
		file = "varianz3-4.log";
		// ask for file
		// BufferedReader in = new BufferedReader(new
		// InputStreamReader(System.in));
		System.out.println("GPS-File?");
		// long IMSI = 262230000000010l;
		/*
		 * if (file == null) { try { file = in.readLine(); } catch (Exception e)
		 * { System.out.println("Cannot read input"); System.exit(-1); } }
		 */

		// parse NMEA log
		NMEAParse gpslog = new NMEAParse(file);

		// testing:
		sqlreader testing = new sqlreader(gpslog, 262230000000010L, 3000l);
		GSMMap testingmap = new GSMMap(testing, 0.00004);
		GoogleOut testingoogle = new GoogleOut(testingmap, "testing.kml");
		testingoogle.write();

		// search in SQL

		long[] IMSIs = { 262012430041708L, 262026003662195L, 262026550055616L,
				262073958646614L, 262123456789177L, 262230000000010L };
		// sqlreader sql = new sqlreader(gpslog, IMSI, 3000l);
		int count = 0;
		for (long l : IMSIs) {
			sqlreader current = new sqlreader(new NMEAParse(file), l, 3000l);
			try {
				GSMMap map = new GSMMap(current, 0.00008);
				System.out.println("Average");
				map.average();
				System.out.println("Outlier");
				map.removeOutlier();
				System.out.println("Gnuplot Signal");
				map.gnuPlotSignalStrength(877, count);
				System.out.println("Gnuplot Delta");
				map.gnuPlotDeltaBTS(877, 880);
				GoogleOut google = new GoogleOut(map, "varianz/GSM-" + l
						+ "-varianz.kml");
				google.write();
				count++;
			} catch (Exception e) {

			}
		}

		// do the Google Magic WITHOUT INTERPOLATION!
		// GSMMapInterpolatorOld testmap = new GSMMapInterpolatorOld(sql,
		// 0.00004);//
		// 0.00004d
		// testmap.average();

		// GoogleOut testfile = new GoogleOut(testmap, "varianz/GSM-" + IMSI
		// + "-varianz.kml");

		/*
		 * get Variance!
		 * 
		 * Timestamp start = new Timestamp(new SimpleDateFormat(
		 * "yyyy-MM-dd HH:mm:ss.S").parse("2011-04-05 14:22:45.0") .getTime());
		 * Timestamp end = new Timestamp(new SimpleDateFormat(
		 * "yyyy-MM-dd HH:mm:ss.S").parse("2011-04-05 14:22:54.0") .getTime());
		 * CalcVariance.Calc(sql, start, end, 877, 6);
		 */

		// do GoogleOut WITH interpolation!

		// GoogleOut testfile2 = new GoogleOut(testmap, "GSMMap.kml");

		// save GSM Map
		// File outfile = new File("GSMout.obj");
		// try {
		// ObjectOutputStream oos = new ObjectOutputStream(
		// new FileOutputStream(outfile));
		// oos.writeObject(testmap);

		// } catch (FileNotFoundException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }

		// try to load
		/*
		 * try { ObjectInputStream ois = new ObjectInputStream(new
		 * FileInputStream( outfile)); GSMMapInterpolatorOld openedGSMmap =
		 * (GSMMapInterpolatorOld) ois .readObject(); // GoogleOut
		 * openedGSMmapout = new GoogleOut(openedGSMmap, // "readout.kml");
		 * 
		 * } catch (FileNotFoundException e) { // TODO Auto-generated catch
		 * block e.printStackTrace(); } catch (IOException e) { // TODO
		 * Auto-generated catch block e.printStackTrace(); }
		 */

	}
}