summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Zahoransky2011-11-22 01:24:45 +0100
committerRichard Zahoransky2011-11-22 01:24:45 +0100
commit53409d0b33e2522e0f7472d5ceaf80be7f835813 (patch)
tree71c23e659909674214b39825766f336a89e8d590
parentLocalization Code. How-To will follow... (diff)
downloadlocalization-53409d0b33e2522e0f7472d5ceaf80be7f835813.tar.gz
localization-53409d0b33e2522e0f7472d5ceaf80be7f835813.tar.xz
localization-53409d0b33e2522e0f7472d5ceaf80be7f835813.zip
"GenerateMap ?" fuer Hilfe. Erzeugt eine GSM-Karte
-rw-r--r--DataStructure/GenerateMap.java104
-rw-r--r--DataStructure/Interpolator.java35
-rw-r--r--compiled/GenerateMap.jarbin0 -> 3756281 bytes
-rw-r--r--compiled/localize.jarbin0 -> 5415307 bytes
-rw-r--r--compiled/showmap.jarbin0 -> 5415307 bytes
5 files changed, 137 insertions, 2 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) {
+
+ }
+ }
+}
diff --git a/DataStructure/Interpolator.java b/DataStructure/Interpolator.java
index 3869255..14310d8 100644
--- a/DataStructure/Interpolator.java
+++ b/DataStructure/Interpolator.java
@@ -4,6 +4,9 @@ import helper.ListBTS;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Date;
@@ -29,6 +32,30 @@ public class Interpolator extends GSMMap {
}
+ public void toGoogleKml(String filename) throws IOException {
+ new GoogleOut(this, filename).write();
+ }
+
+ /**
+ * Saves GSM map as Object on filesystem
+ *
+ * @param filename
+ */
+ public void save(String filename) {
+
+ try {
+ FileOutputStream fos = new FileOutputStream(filename);
+ ObjectOutputStream out = new ObjectOutputStream(fos);
+ out.writeObject(this);
+ out.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ System.out.println("Cannot write Object to filesystem");
+ }
+ System.out.println("GSMmap saved");
+ }
+
/**
* Interpolates every Point on the map,every arfcn
*/
@@ -346,19 +373,23 @@ public class Interpolator extends GSMMap {
public int x;
public int y;
public SingleBTS what;
+
public voronoi primary;
@Override
public void run() {
- if (x < Xcoords.length && y < Ycoords.length)
+ if (x < Xcoords.length && y < Ycoords.length) {
+ voronoi primary = new voronoi();
+ primary.sortNode(Interpolator.this, what.ARFCN, 1);
interpolateAT(x, y, what, primary);
+ }
}
public interpolateThread(int x, int y, SingleBTS what, voronoi primary) {
this.x = x;
this.y = y;
this.what = what;
- this.primary = primary;
+ // this.primary=primary;
}
}
diff --git a/compiled/GenerateMap.jar b/compiled/GenerateMap.jar
new file mode 100644
index 0000000..5b4eb61
--- /dev/null
+++ b/compiled/GenerateMap.jar
Binary files differ
diff --git a/compiled/localize.jar b/compiled/localize.jar
new file mode 100644
index 0000000..ed448ea
--- /dev/null
+++ b/compiled/localize.jar
Binary files differ
diff --git a/compiled/showmap.jar b/compiled/showmap.jar
new file mode 100644
index 0000000..803ecaa
--- /dev/null
+++ b/compiled/showmap.jar
Binary files differ