summaryrefslogtreecommitdiffstats
path: root/DataStructure/GenerateMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'DataStructure/GenerateMap.java')
-rw-r--r--DataStructure/GenerateMap.java104
1 files changed, 104 insertions, 0 deletions
diff --git a/DataStructure/GenerateMap.java b/DataStructure/GenerateMap.java
new file mode 100644
index 0000000..ff43b89
--- /dev/null
+++ b/DataStructure/GenerateMap.java
@@ -0,0 +1,104 @@
+package gui;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+
+import DataStructure.Interpolator;
+import Parse.NMEAParse;
+import Parse.sqlreader;
+
+public class GenerateMap {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ for (String s : args) {
+ if (s.contains("?") || s.contains("help")) {
+ printHelp();
+ System.exit(1);
+ }
+
+ }
+ double resolution = Double.parseDouble(args[0]);
+ if (resolution == 0) {
+ printHelp();
+ System.exit(-1);
+ }
+ long imsi = Long.parseLong(args[1]);
+ if (imsi == 0) {
+ printHelp();
+ System.exit(-1);
+ }
+
+ // everything okay until now... do GSMmap
+ NMEAParse nmea = new NMEAParse(args[2]);
+ sqlreader sql = null;
+ sql = new sqlreader(nmea, imsi, 1000);
+
+ for (int i = 3; i < args.length; i++) {
+ nmea = new NMEAParse(args[i]);
+ sql.merge(new sqlreader(nmea, imsi, 1000));
+
+ }
+
+ Interpolator map = new Interpolator(sql, resolution);
+ try {
+ map.toGoogleKml("measured.kml");
+ } catch (IOException e) {
+ }
+ System.out
+ .println("GSMmap read successfully... Interpolating. This will take some time");
+ map.interpolateVR();
+ try {
+ map.toGoogleKml("interpolated.kml");
+ } catch (IOException e) {
+ }
+ backupOfOldMap();
+ map.save("parallel-strictdB-BER.obj");
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ System.out.println("Java SQL class not found");
+ printHelp();
+ System.exit(-2);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ printHelp();
+ System.out.println("SQL error. Maybe no Internet?");
+ System.exit(-2);
+ }
+ }
+
+ private static void printHelp() {
+ System.out.println();
+ System.out.println();
+ System.out
+ .println("Usage: GenerateMap [resolution] [IMSI] [NMEA files]");
+ System.out.println();
+ System.out
+ .println("Resolution is in degree Longitude and Latitude. For example a resolution of 0.00008 will generate tiles with a size of 9 x 6 meter");
+ System.out.println("more than one NMEA (GPS) logfile can be given");
+ System.out.println();
+ System.out
+ .println("Map will automatically be interpolated and stored as parallel-strictdB-BER.obj");
+ System.out
+ .println("previous map will be renamed to parallel-strictdB-BER.old");
+
+ }
+
+ private static void backupOfOldMap() {
+ try {
+ File test = new File("parallel-strictdB-BER.obj");
+ if (test.isFile()) {
+ new File("parallel-strictdB-BER.old").delete();
+ test.renameTo(new File("parallel-strictdB-BER.old"));
+ }
+ } catch (SecurityException e) {
+
+ }
+ }
+}