diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 69906b222ae0ab0a83090e6c473d7966ec36299d..8a6dc5cf21fd6057e5d1c4feeb50a5dcc2930976 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -28,6 +28,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
@@ -69,6 +70,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
diff --git a/pom.xml b/pom.xml
index 62b1d7a0a9571076c8b1f5be79f21c3636ad652b..22f11fc5eecb429ce37ef66407f6fd1ad10bfbb7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -213,9 +213,9 @@
4.3.10.Final
-
-
+ org.xerial sqlite-jdbc
+ 3.7.2
+
org.hsqldb
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/SmarterMovementModelNew.java b/src/de/tud/kom/p2psim/impl/topology/movement/SmarterMovementModelNew.java
index 3da715f84fba484a6a2512c0825cca675f1dd83b..f06796261f9e26d4fb6d1a5dc7edad117bc283fd 100644
--- a/src/de/tud/kom/p2psim/impl/topology/movement/SmarterMovementModelNew.java
+++ b/src/de/tud/kom/p2psim/impl/topology/movement/SmarterMovementModelNew.java
@@ -26,10 +26,12 @@ import java.util.Set;
import de.tud.kom.p2psim.api.topology.movement.MovementModel;
import de.tud.kom.p2psim.api.topology.movement.SimLocationActuator;
+import de.tud.kom.p2psim.impl.topology.movement.modularosm.mapvisualization.IMapVisualization;
import de.tud.kom.p2psim.impl.topology.movement.smarter.dataanalyzer.Analyzer;
import de.tud.kom.p2psim.impl.topology.movement.smarter.dataanalyzer.Statistics;
import de.tud.kom.p2psim.impl.topology.movement.smarter.host.SmarterHost;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
+import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
@@ -43,6 +45,8 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
* @version 1.0, 12.06.2018
*/
public class SmarterMovementModelNew implements MovementModel, EventHandler {
+ protected IMapVisualization mapVisualization;
+
private static final Location DEFAULT_LOCATION = new PositionVector(Double.NaN, Double.NaN);
public static SmarterMovementModelNew movement;
protected long timeBetweenMoveOperations;
@@ -57,11 +61,22 @@ public class SmarterMovementModelNew implements MovementModel, EventHandler {
public SmarterMovementModelNew() {
movement = this;
dataAnalyzed = false;
+
+ // scheduling initalization!
+ Event.scheduleImmediately(this, null, 42);
+
+ }
+
+ private void initialize() {
// TODO get bool from xml to decide whether to analyze data or not
if(!dataAnalyzed)
analyzeData();
+
+ if (mapVisualization != null) {
+ VisualizationInjector.injectComponent(mapVisualization);
+ }
}
-
+
/**
* Returns the instance of this class
* @return instance of this class
@@ -125,22 +140,31 @@ public class SmarterMovementModelNew implements MovementModel, EventHandler {
*/
@Override
public void eventOccurred(Object content, int type) {
- SmarterHost host = (SmarterHost) content;
+
+ if(type == 42) {
+ initialize();
+ }
+ else {
+ SmarterHost host = (SmarterHost) content;
- Location location = host.getNextLocation();
+ Location location = host.getNextLocation();
- if (location != null) {
- host.getActuator().updateCurrentLocation(location);
- }
+ if (location != null) {
+ host.getActuator().updateCurrentLocation(location);
+ }
- if (host.tryNextStep()) {
- long sleepTime = host.getSleepTime();
+ if (host.tryNextStep()) {
+ long sleepTime = host.getSleepTime();
- // Reschedule next step
- Event.scheduleWithDelay(sleepTime, this, host, 0);
+ // Reschedule next step
+ Event.scheduleWithDelay(sleepTime, this, host, 0);
+ }
}
+
+
}
+
/**
* Called once during simulation setup for each host. Creates a SmarterHost object at a default location.
*/
@@ -181,4 +205,10 @@ public class SmarterMovementModelNew implements MovementModel, EventHandler {
public long getTimeBetweenMoveOperations() {
return timeBetweenMoveOperations;
}
+
+ public void setIMapVisualization(IMapVisualization mapVisualization) {
+ this.mapVisualization = mapVisualization;
+ }
+
+
}
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/GPSCalculation.java b/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/GPSCalculation.java
index 6a16929d3e42349241b2937180eee9aefe7029ae..fdd88b1abd2aad41f93aad4563ab58b99e9f5a9f 100644
--- a/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/GPSCalculation.java
+++ b/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/GPSCalculation.java
@@ -21,6 +21,8 @@
package de.tud.kom.p2psim.impl.topology.movement.modularosm;
import de.tud.kom.p2psim.api.topology.Topology;
+import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.AttractionPointImpl;
+import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tudarmstadt.maki.simonstrator.api.Binder;
@@ -134,7 +136,29 @@ public class GPSCalculation {
public void setLonCenter(double lonCenter) {
this.lonCenter = lonCenter;
}
-
+
+ /**
+ * Projects the gps coordinates in the given gps window to the world-coordinates given in world-dimensions
+ * @param lat
+ * @param lon
+ * @return The projected position in world-dimensions
+ */
+ public static PositionVector transformGPSWindowToOwnWorld(double lat, double lon) {
+ double x = getWorldDimensionsX() * (lon - getLonLeft())/(getLonRight() - getLonLeft());
+ //Invert the y value, because in Java Swing we start drawing in the upper left corner instead in the lower left one
+ double y = getWorldDimensionsY() - getWorldDimensionsY() * (lat - getLatLower())/(getLatUpper() - getLatLower());
+ return new PositionVector(x, y);
+ }
+
+ public static boolean isWithinSimulationBoundaries(double lat, double lon) {
+ if(lat > getLatLower() && lat < getLatUpper() &&
+ lon > getLonLeft() && lon < getLonRight()) {
+ return true;
+ }
+ else return false;
+ }
+
+
/**
* Formula http://wiki.openstreetmap.org/wiki/Zoom_levels
*
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java b/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java
index 39a4b61aa3ed233df2e3b961fe3e63fdea72ee31..d3f874af0d0fd020de0a1c3edebc8345e33728a4 100644
--- a/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java
+++ b/src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java
@@ -54,14 +54,9 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
*/
public class JSONAttractionGenerator implements IAttractionGenerator {
- private PositionVector worldDimensions;
-
private int numberOfAttractionPoints;
private String placementJsonFile;
- private double latLeft; //Values from -90 to 90; always smaller than latRight
- private double latRight; //Values from -90 to 90
- private double lonLeft; //Values from -180 to 180; Always smaller than lonRight
- private double lonRight; //Values from -180 to 180
+
private double maximumRadius = -1; // Values >= 0, or -1 if radius taken from file
/**
@@ -70,28 +65,8 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
http://overpass-api.de/api/interpreter?data=%5Bout:json%5D;node%5Bamenity=bar%5D%2849%2E4813%2C8%2E5590%2C49%2E9088%2C8%2E7736%29%3Bout%3B
*/
@XMLConfigurableConstructor({"numberOfAttractionPoints"})
- public JSONAttractionGenerator(int numberOfAttractionPoints) {
- this.worldDimensions = Binder.getComponentOrNull(Topology.class)
- .getWorldDimensions();
-
- this.numberOfAttractionPoints = numberOfAttractionPoints;
- latLeft = GPSCalculation.getLatLower();
- latRight = GPSCalculation.getLatUpper();
- lonLeft = GPSCalculation.getLonLeft();
- lonRight = GPSCalculation.getLonRight();
- }
-
- /**
- * Projects the gps coordinates in the given gps window to the world-coordinates given in world-dimensions
- * @param lat
- * @param lon
- * @return The projected position in world-dimensions
- */
- private PositionVector transformGPSWindowToOwnWorld(double lat, double lon) {
- double x = worldDimensions.getX() * (lon - lonLeft)/(lonRight - lonLeft);
- //Invert the y value, because in Java Swing we start drawing in the upper left corner instead in the lower left one
- double y = worldDimensions.getY() - worldDimensions.getY() * (lat - latLeft)/(latRight - latLeft);
- return new PositionVector(x, y);
+ public JSONAttractionGenerator(int numberOfAttractionPoints) {
+ this.numberOfAttractionPoints = numberOfAttractionPoints;
}
@Override
@@ -131,11 +106,10 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
AttractionPointImpl ap;
// check that the point is within the simulation boundaries
- if(lat > latLeft && lat < latRight &&
- lon > lonLeft && lon < lonRight) {
+ if(GPSCalculation.isWithinSimulationBoundaries(lat, lon)) {
// initialize the attraction point with basic information, will be filled now...
- ap = new AttractionPointImpl(barname, transformGPSWindowToOwnWorld(lat, lon));
+ ap = new AttractionPointImpl(barname, GPSCalculation.transformGPSWindowToOwnWorld(lat, lon));
attractionPoints.add(ap);
// the following setters are allowed to fail
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/DataConverter.java b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/DataConverter.java
new file mode 100644
index 0000000000000000000000000000000000000000..4372c207c515fdc3e7c2ef0ea3bfc94e02062726
--- /dev/null
+++ b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/DataConverter.java
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
+ *
+ * This file is part of PeerfactSim.KOM.
+ *
+ * PeerfactSim.KOM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * PeerfactSim.KOM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PeerfactSim.KOM. If not, see .
+ *
+ */
+
+package de.tud.kom.p2psim.impl.topology.movement.smarter;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FilenameUtils;
+
+import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
+import de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction.IAttractionGenerator;
+import de.tud.kom.p2psim.impl.topology.util.PositionVector;
+import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.IAttractionPoint;
+
+public class DataConverter {
+
+ public DataConverter() {
+ readTraceDatabases();
+ }
+
+
+ public static void readTraceDatabases() {
+
+ List aps = IAttractionGenerator.attractionPoints;
+
+
+ DataGrabber grabber = new DataGrabber();
+
+ // Set the path to folder containing the .sqlite files here
+ String sqliteFolderPath = "D:/Simonstrator/simrunner/smarter/databases/";
+ List filePaths = DataConverter.getFilePaths(sqliteFolderPath);
+
+ try {
+ System.out.println(Class.forName("org.sqlite.JDBC"));
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ for (String filePath : filePaths) {
+ grabber.connect(filePath);
+ List listOfEntries = grabber.select("SELECT * FROM gps_data");
+ grabber.disconnect();
+
+ // Analyze data
+ for (SmarterDBEntry entry : listOfEntries) {
+ int id = entry.get_id();
+ String timestamp = entry.getTimestamp();
+ double lat = entry.getLatitude();
+ double lon = entry.getLongitude();
+ double alt = entry.getAltitude();
+ double acc = entry.getAccuracy();
+
+
+
+ if(GPSCalculation.isWithinSimulationBoundaries(lat, lon)) {
+ PositionVector p = GPSCalculation.transformGPSWindowToOwnWorld(lat, lon);
+
+ for (IAttractionPoint ap : aps) {
+
+ if(ap.distanceTo(p) <= ap.getRadius()) {
+ System.out.println(ap.getName());
+ System.out.println(id + ": " + lat + " / " + lon + " / " + alt + " +/- " + acc + " --- " + timestamp);
+ System.out.println(p);
+ }
+
+ }
+
+
+ }
+ }
+
+
+ return;
+ }
+
+
+
+ }
+
+
+ /**
+ * Returns a list of full file paths of a given directory
+ *
+ * @param directory
+ * The
+ * @return
+ */
+ public static ArrayList getFilePaths(String directory) {
+ File folder = new File(directory);
+ File[] listOfFiles = folder.listFiles();
+
+ ArrayList filePaths = new ArrayList();
+
+ if (listOfFiles.length == 0) {
+ System.out.println("No files in directory");
+ return null;
+ }
+
+ for (int i = 0; i < listOfFiles.length; i++) {
+ if (listOfFiles[i].isFile()) {
+
+ if(listOfFiles[i].getName().contains(".db")) {
+ filePaths.add(directory + listOfFiles[i].getName());
+ }
+
+ }
+ }
+ return filePaths;
+ }
+
+ /*
+ * @author Marcel Verst
+ */
+ private static class SmarterDBEntry {
+ // All columns of the row
+ public int _id;
+ double longitude;
+ double latitude;
+ double altitude;
+ double accuracy;
+ String timestamp;
+
+ /**
+ * Creates SmarterDBEntry object
+ *
+ * @param _id
+ * the id entry
+ * @param longitude
+ * the longitude entry
+ * @param latitude
+ * the latitude entry
+ * @param altitude
+ * the altitude entry
+ * @param accuracy
+ * the accuracy entry
+ * @param timestamp
+ * the timestamp entry
+ */
+ public SmarterDBEntry(int _id, double longitude, double latitude, double altitude, double accuracy, String timestamp) {
+ super();
+ this._id = _id;
+ this.longitude = longitude;
+ this.latitude = latitude;
+ this.altitude = altitude;
+ this.accuracy = accuracy;
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * Print entry
+ *
+ * @return String containing all entries of the row
+ */
+ @Override
+ public String toString() {
+ return "DBEntry [_id=" + _id + ", longitude=" + longitude + ", latitude=" + latitude + ", altitude=" + altitude
+ + ", accuracy=" + accuracy + ", timestamp=" + timestamp + "]";
+ }
+
+ /**
+ * Gets the ID
+ *
+ * @return _id
+ */
+ public int get_id() {
+ return _id;
+ }
+
+ /**
+ * Gets the longitude
+ *
+ * @return longitude
+ */
+ public double getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * Gets the latitude
+ *
+ * @return latitude
+ */
+ public double getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * Gets the altitude
+ *
+ * @return altitude
+ */
+ public double getAltitude() {
+ return altitude;
+ }
+
+ /**
+ * Gets the accuracy
+ *
+ * @return accuracy of GPS signal
+ */
+ public double getAccuracy() {
+ return accuracy;
+ }
+
+ /**
+ * Gets the timestamp
+ *
+ * @return timestamp
+ */
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+
+ }
+
+ /**
+ * DataGrabber class is responsible for establishing a connection to a database
+ * and to query the data
+ *
+ * @author Marcel Verst
+ * @version 26.05.2018
+ */
+ private static class DataGrabber {
+ // The connection to the database.
+ private Connection conn;
+
+ /**
+ * DataGrabber constructor, initializes the connection
+ */
+ public DataGrabber() {
+ conn = null;
+ }
+
+ /**
+ * Connect to a database specified in params.properties Code from
+ * "http://www.sqlitetutorial.net/sqlite-java/sqlite-jdbc-driver/"
+ *
+ * @throws SQLException
+ * if the connection cannot be established
+ */
+ public void connect(String filePath) {
+ try {
+ // db parameters
+ String url = "jdbc:sqlite:" + filePath;
+ // create a connection to the database
+
+ System.out.println(url);
+
+ conn = DriverManager.getConnection(url);
+
+ System.out.println("Connection to " + filePath + " has been established.");
+
+ } catch (SQLException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ /**
+ * Disconnects database
+ *
+ * @throws SQLException
+ * if disconnection failed
+ */
+ public void disconnect() {
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Queries the database with a given query string, stores the values within an
+ * ArrayList and returns it for further analyzes
+ *
+ * @param selection
+ * The SQL query
+ * @return listOfEntries ArrayList object containing DBEntry types
+ * @throws SQLException
+ * if there are problems with connecting to the database
+ */
+ public ArrayList select(String selection) {
+ ArrayList listOfEntries = new ArrayList();
+ try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(selection)) {
+
+ // loop through the result set
+ while (rs.next()) {
+ int _id = rs.getInt("_id");
+ double longitude = rs.getDouble("longitude");
+ double latitude = rs.getDouble("latitude");
+ double altitude = rs.getDouble("altitude");
+ double accuracy = rs.getDouble("accuracy");
+ String timestamp = rs.getString("timestamp");
+
+ SmarterDBEntry entry = new SmarterDBEntry(_id, longitude, latitude, altitude, accuracy, timestamp);
+ listOfEntries.add(entry);
+ }
+ } catch (SQLException e) {
+ System.out.println(e.getMessage());
+ }
+ return listOfEntries;
+ }
+ }
+}
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DBEntry.java b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DBEntry.java
deleted file mode 100644
index f8224d05b495764ca5f352b55c5277712d1f2c46..0000000000000000000000000000000000000000
--- a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DBEntry.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2005-2010 KOM � Multimedia Communications Lab
- *
- * This file is part of PeerfactSim.KOM.
- *
- * PeerfactSim.KOM is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * PeerfactSim.KOM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PeerfactSim.KOM. If not, see .
- *
- */
-package de.tud.kom.p2psim.impl.topology.movement.smarter.dataanalyzer;
-
-/**
- * Represents a row of the gps_data table from a database
- *
- * @author Marcel Verst
- * @version 26.05.2018
- */
-public class DBEntry {
- // All columns of the row
- public int _id;
- double longitude;
- double latitude;
- double altitude;
- double accuracy;
- String timestamp;
-
- /**
- * Creates DBEntry object
- *
- * @param _id
- * the id entry
- * @param longitude
- * the longitude entry
- * @param latitude
- * the latitude entry
- * @param altitude
- * the altitude entry
- * @param accuracy
- * the accuracy entry
- * @param timestamp
- * the timestamp entry
- */
- public DBEntry(int _id, double longitude, double latitude, double altitude, double accuracy, String timestamp) {
- super();
- this._id = _id;
- this.longitude = longitude;
- this.latitude = latitude;
- this.altitude = altitude;
- this.accuracy = accuracy;
- this.timestamp = timestamp;
- }
-
- /**
- * Print entry
- *
- * @return String containing all entries of the row
- */
- @Override
- public String toString() {
- return "DBEntry [_id=" + _id + ", longitude=" + longitude + ", latitude=" + latitude + ", altitude=" + altitude
- + ", accuracy=" + accuracy + ", timestamp=" + timestamp + "]";
- }
-
- /**
- * Gets the ID
- *
- * @return _id
- */
- public int get_id() {
- return _id;
- }
-
- /**
- * Sets the ID
- *
- * @param _id
- */
- public void set_id(int _id) {
- this._id = _id;
- }
-
- /**
- * Gets the longitude
- *
- * @return longitude
- */
- public double getLongitude() {
- return longitude;
- }
-
- /**
- * Sets the longitude
- *
- * @param longitude
- */
- public void setLongitude(double longitude) {
- this.longitude = longitude;
- }
-
- /**
- * Gets the latitude
- *
- * @return latitude
- */
- public double getLatitude() {
- return latitude;
- }
-
- /**
- * Sets the latitude
- *
- * @param latitude
- */
- public void setLatitude(double latitude) {
- this.latitude = latitude;
- }
-
- /**
- * Gets the altitude
- *
- * @return altitude
- */
- public double getAltitude() {
- return altitude;
- }
-
- /**
- * Sets the altitude
- *
- * @param altitude
- */
- public void setAltitude(double altitude) {
- this.altitude = altitude;
- }
-
- /**
- * Gets the accuracy
- *
- * @return accuracy of GPS signal
- */
- public double getAccuracy() {
- return accuracy;
- }
-
- /**
- * Sets the accuracy
- *
- * @param accuracy
- */
- public void setAccuracy(double accuracy) {
- this.accuracy = accuracy;
- }
-
- /**
- * Gets the timestamp
- *
- * @return timestamp
- */
- public String getTimestamp() {
- return timestamp;
- }
-
- /**
- * Sets the timestamp
- *
- * @param timestamp
- */
- public void setTimestamp(String timestamp) {
- this.timestamp = timestamp;
- }
-}
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DataGrabber.java b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DataGrabber.java
deleted file mode 100644
index 72073f74a2c77556836a8dfa8eeb6ac17a732e99..0000000000000000000000000000000000000000
--- a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/dataanalyzer/DataGrabber.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2005-2010 KOM � Multimedia Communications Lab
- *
- * This file is part of PeerfactSim.KOM.
- *
- * PeerfactSim.KOM is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * PeerfactSim.KOM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PeerfactSim.KOM. If not, see .
- *
- */
-
-package de.tud.kom.p2psim.impl.topology.movement.smarter.dataanalyzer;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-
-/**
- * DataGrabber class is responsible for establishing a connection to a database
- * and to query the data
- *
- * @author Marcel Verst
- * @version 26.05.2018
- */
-public class DataGrabber {
- // The connection to the database.
- private Connection conn;
-
- /**
- * DataGrabber constructor, initializes the connection
- */
- public DataGrabber() {
- conn = null;
- }
-
- /**
- * Connect to a database specified in params.properties Code from
- * "http://www.sqlitetutorial.net/sqlite-java/sqlite-jdbc-driver/"
- *
- * @throws SQLException
- * if the connection cannot be established
- */
- public void connect(String filePath) {
- try {
- // db parameters
- String url = "jdbc:sqlite:" + filePath;
- // create a connection to the database
- conn = DriverManager.getConnection(url);
-
- System.out.println("Connection to " + filePath + " has been established.");
-
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
-
- /**
- * Disconnects database
- *
- * @throws SQLException
- * if disconnection failed
- */
- public void disconnect() {
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Queries the database with a given query string, stores the values within an
- * ArrayList and returns it for further analyzes
- *
- * @param selection
- * The SQL query
- * @return listOfEntries ArrayList object containing DBEntry types
- * @throws SQLException
- * if there are problems with connecting to the database
- */
- public ArrayList select(String selection) {
- ArrayList listOfEntries = new ArrayList();
- try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(selection)) {
-
- // loop through the result set
- while (rs.next()) {
- int _id = rs.getInt("_id");
- double longitude = rs.getDouble("longitude");
- double latitude = rs.getDouble("latitude");
- double altitude = rs.getDouble("altitude");
- double accuracy = rs.getDouble("accuracy");
- String timestamp = rs.getString("timestamp");
-
- DBEntry entry = new DBEntry(_id, longitude, latitude, altitude, accuracy, timestamp);
- listOfEntries.add(entry);
- }
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- return listOfEntries;
- }
-}
diff --git a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/host/SmarterHost.java b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/host/SmarterHost.java
index 9e78d32d7eab207064fb8282ae9af815b1286f31..ee98fba60ca19947f77aa062bdd13f0cc03a5d81 100644
--- a/src/de/tud/kom/p2psim/impl/topology/movement/smarter/host/SmarterHost.java
+++ b/src/de/tud/kom/p2psim/impl/topology/movement/smarter/host/SmarterHost.java
@@ -97,7 +97,6 @@ public class SmarterHost {
nextLocation = new PositionVector(positionX, positionY);
_sleepTime = nextTimestamp * SmarterMovementModelNew.getInstance().getTimeBetweenMoveOperations() - Time.getCurrentTime();
-
return true;
}
}