From 53409d0b33e2522e0f7472d5ceaf80be7f835813 Mon Sep 17 00:00:00 2001 From: Richard Zahoransky Date: Tue, 22 Nov 2011 01:24:45 +0100 Subject: "GenerateMap ?" fuer Hilfe. Erzeugt eine GSM-Karte --- DataStructure/GenerateMap.java | 104 ++++++++++++++++++++++++++++++++++++++++ DataStructure/Interpolator.java | 35 +++++++++++++- compiled/GenerateMap.jar | Bin 0 -> 3756281 bytes compiled/localize.jar | Bin 0 -> 5415307 bytes compiled/showmap.jar | Bin 0 -> 5415307 bytes 5 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 DataStructure/GenerateMap.java create mode 100644 compiled/GenerateMap.jar create mode 100644 compiled/localize.jar create mode 100644 compiled/showmap.jar 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 Binary files /dev/null and b/compiled/GenerateMap.jar differ diff --git a/compiled/localize.jar b/compiled/localize.jar new file mode 100644 index 0000000..ed448ea Binary files /dev/null and b/compiled/localize.jar differ diff --git a/compiled/showmap.jar b/compiled/showmap.jar new file mode 100644 index 0000000..803ecaa Binary files /dev/null and b/compiled/showmap.jar differ -- cgit v1.2.3-55-g7522