Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
59d17304ad | |||
906df05c6c | |||
a685f972bf | |||
![]() |
53528a82e9 |
@ -43,5 +43,6 @@ dependencies {
|
|||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
|
|
||||||
implementation("com.google.guava:guava:30.1.1-jre")
|
implementation("com.google.guava:guava:30.1.1-jre")
|
||||||
|
implementation ('com.lemmingapex.trilateration:trilateration:1.0.2')
|
||||||
|
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
//################################################################## vvv SensorParameter vvv ##############################################################################
|
//################################################################## vvv SensorParameter vvv ##############################################################################
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private static final float mUpperThreshold = 1.0f; // für Emulator auf 1.5 setzen
|
private static final float mUpperThreshold = 0.075f; // für Emulator auf 1.5 setzen
|
||||||
private static final float mLowerThreshold = 0.5f; // für Emulator auf 0.5 setzen
|
private static final float mLowerThreshold = 0.5f; // für Emulator auf 0.5 setzen
|
||||||
private static final long mShakeDetectionLockTimeMicroSeconds = 3500;
|
private static final long mShakeDetectionLockTimeMicroSeconds = 3500;
|
||||||
private float mAccel;
|
private float mAccel;
|
||||||
@ -101,15 +101,17 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
{
|
{
|
||||||
//TextView txtEarthquake = (TextView) findViewById(R.id.txtEarthquake);
|
//TextView txtEarthquake = (TextView) findViewById(R.id.txtEarthquake);
|
||||||
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
||||||
Objects.requireNonNull(mSensorManager).registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
|
Objects.requireNonNull(mSensorManager).registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);
|
||||||
mAccel = 1f;
|
mAccel = 0.05f;
|
||||||
mAccelCurrent = SensorManager.GRAVITY_EARTH;
|
mAccelCurrent = SensorManager.GRAVITY_EARTH;
|
||||||
mAccelLast = SensorManager.GRAVITY_EARTH;
|
mAccelLast = SensorManager.GRAVITY_EARTH;
|
||||||
mShakeDetectionIsActive = false;
|
mShakeDetectionIsActive = false;
|
||||||
mShakeDetected = false;
|
mShakeDetected = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final SensorEventListener mSensorListener = new SensorEventListener() {
|
private final SensorEventListener mSensorListener = new SensorEventListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
float x = event.values[0];
|
float x = event.values[0];
|
||||||
@ -119,11 +121,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
|
mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
|
||||||
float delta = mAccelCurrent - mAccelLast;
|
float delta = mAccelCurrent - mAccelLast;
|
||||||
mAccel = mAccel * 0.9f + delta;
|
mAccel = mAccel * 0.9f + delta;
|
||||||
// Log.d(TAG,"mAccel: "+ mAccel);
|
Log.d(TAG,"mAccel: "+ mAccel);
|
||||||
if (mShakeDetectionIsActive && !mShakeDetected) {
|
if (mShakeDetectionIsActive && !mShakeDetected) {
|
||||||
if(Math.abs(mAccel) > mUpperThreshold) {
|
if(Math.abs(mAccel) > mUpperThreshold) {
|
||||||
|
|
||||||
new CountDownTimer(1000, 10) {
|
new CountDownTimer(500, 10) {
|
||||||
|
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
mShakeDetectionIsActive = false;
|
mShakeDetectionIsActive = false;
|
||||||
@ -378,34 +380,83 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void analyzeDBchanges(DataSnapshot data)
|
public void analyzeDBchanges(DataSnapshot data)
|
||||||
{
|
{
|
||||||
|
for (int i=1; i<=data.getChildrenCount(); i++)
|
||||||
|
{
|
||||||
|
if(analyzeForFullIDG(data,i) || analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
||||||
|
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
||||||
|
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
||||||
|
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
|
||||||
|
String dbSlotStringContent = getSlotString(data,i);
|
||||||
|
String displayContent;
|
||||||
|
switch (i){
|
||||||
|
case 1:
|
||||||
|
displayContent = txtDevice1.getText().toString();
|
||||||
|
if(!displayContent.equals(dbSlotStringContent))
|
||||||
|
{
|
||||||
|
if(analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
txtDevice1.setText("");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
txtDevice1.setText(dbSlotStringContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
displayContent = txtDevice2.getText().toString();
|
||||||
|
if(!displayContent.equals(dbSlotStringContent))
|
||||||
|
{
|
||||||
|
if(analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
txtDevice2.setText("");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
txtDevice2.setText(dbSlotStringContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
displayContent = txtDevice3.getText().toString();
|
||||||
|
if(!displayContent.equals(dbSlotStringContent))
|
||||||
|
{
|
||||||
|
if(analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
txtDevice3.setText("");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
txtDevice3.setText(dbSlotStringContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
displayContent = txtDevice4.getText().toString();
|
||||||
|
if(!displayContent.equals(dbSlotStringContent))
|
||||||
|
{
|
||||||
|
if(analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
txtDevice4.setText("");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
txtDevice4.setText(dbSlotStringContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int takenIDG = 0;
|
int takenIDG = 0;
|
||||||
for (int i=1; i<=data.getChildrenCount(); i++)
|
for (int i=1; i<=data.getChildrenCount(); i++)
|
||||||
{
|
{
|
||||||
if(analyzeForFullIDG(data,i))
|
if(analyzeForFullIDG(data,i))
|
||||||
{
|
{
|
||||||
//Ein voller IDG slot
|
|
||||||
takenIDG++;
|
takenIDG++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(takenIDG>=1 && takenIDG <=5)
|
|
||||||
{
|
|
||||||
//Kommt bei einer neuen vollen IDG ins Display
|
|
||||||
for(writtenDevices = writtenDevices; writtenDevices <= takenIDG; writtenDevices++)
|
|
||||||
{
|
|
||||||
setDisplayText(data,writtenDevices);
|
|
||||||
enableDisplayReset = true; //Für DB zurücksetzen
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
if(enableDisplayReset)
|
|
||||||
{
|
|
||||||
resetDisplayText();
|
|
||||||
enableDisplayReset = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Bei genau 3 Einträgen:
|
|
||||||
if(takenIDG >= 3 && allowCalculation)
|
if(takenIDG >= 3 && allowCalculation)
|
||||||
{
|
{
|
||||||
Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
|
||||||
@ -414,7 +465,17 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
btnEarthquake.setEnabled(true);
|
btnEarthquake.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public String getSlotString(DataSnapshot data,int i)
|
||||||
|
{
|
||||||
|
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
||||||
|
String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
||||||
|
String breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
||||||
|
String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||||
|
String timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||||
|
String ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
|
||||||
|
String databaseSlotString = "Device ID " + i + ": "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n";
|
||||||
|
return databaseSlotString;
|
||||||
|
}
|
||||||
public boolean analyzeForFullIDG(DataSnapshot data, int i)
|
public boolean analyzeForFullIDG(DataSnapshot data, int i)
|
||||||
{
|
{
|
||||||
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
||||||
@ -434,49 +495,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplayText(DataSnapshot data, int i)
|
|
||||||
{
|
|
||||||
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
|
||||||
String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
|
||||||
String breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
|
||||||
String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
|
||||||
String timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
|
||||||
String ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
|
|
||||||
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
|
||||||
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
|
||||||
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
|
||||||
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
|
|
||||||
switch (i){
|
|
||||||
case 1:
|
|
||||||
txtDevice1.setText("Device ID 1: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
txtDevice2.setText("Device ID 2: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
txtDevice3.setText("Device ID 3: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
txtDevice4.setText("Device ID 4: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetDisplayText()
|
|
||||||
{
|
|
||||||
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
|
||||||
btnEarthquake.setEnabled(false);
|
|
||||||
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
|
||||||
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
|
||||||
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
|
||||||
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
|
|
||||||
txtDevice1.setText("");
|
|
||||||
txtDevice2.setText("");
|
|
||||||
txtDevice3.setText("");
|
|
||||||
txtDevice4.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getandroidid ()
|
public String getandroidid ()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public class Detektionssignal {
|
|||||||
this.koordinaten = koordinaten;
|
this.koordinaten = koordinaten;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGeschwErdbeben() {
|
public double getGeschwErdbeben() {
|
||||||
return geschwErdbeben;
|
return geschwErdbeben;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +44,6 @@ public class Detektionssignal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Koordinaten koordinaten;
|
public Koordinaten koordinaten;
|
||||||
public int geschwErdbeben;
|
public double geschwErdbeben;
|
||||||
public LocalDateTime ankunftsZeit;
|
public LocalDateTime ankunftsZeit;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.os.Build;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import de.edotzlaff.detection.detektion.berechnung.Endpunkt;
|
import de.edotzlaff.detection.detektion.berechnung.Endpunkt;
|
||||||
import de.edotzlaff.detection.detektion.berechnung.EndpunktVerbindung;
|
import de.edotzlaff.detection.detektion.berechnung.EndpunktVerbindung;
|
||||||
import de.edotzlaff.detection.detektion.berechnung.EpizentrumRechnung;
|
import de.edotzlaff.detection.detektion.berechnung.EpizentrumRechnung;
|
||||||
@ -17,7 +18,7 @@ import java.util.Objects;
|
|||||||
public class Erdbeben {
|
public class Erdbeben {
|
||||||
|
|
||||||
//ToDO anpassen an Szenario umso mehr umso wahrscheinlich ein Ergebnis, oder Abbruchbedingung mit do while
|
//ToDO anpassen an Szenario umso mehr umso wahrscheinlich ein Ergebnis, oder Abbruchbedingung mit do while
|
||||||
public static final Integer SCHLEIFENDURCHLAUFTE = 2000;
|
public static final Integer SCHLEIFENDURCHLAUFTE = 200;
|
||||||
private static final String TAG = "ERDBEBEN";
|
private static final String TAG = "ERDBEBEN";
|
||||||
|
|
||||||
private Epizentrum epizentrum;
|
private Epizentrum epizentrum;
|
||||||
@ -37,10 +38,8 @@ public class Erdbeben {
|
|||||||
return nutzerDaten.size();
|
return nutzerDaten.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDetektionssignalList(ArrayList<Detektionssignal> detektionssignale)
|
public void addDetektionssignalList(ArrayList<Detektionssignal> detektionssignale) {
|
||||||
{
|
for (int i = 0; i < detektionssignale.size(); i++) {
|
||||||
for (int i = 0; i< detektionssignale.size(); i++)
|
|
||||||
{
|
|
||||||
nutzerDaten.put(detektionssignale.get(i).getDeviceId() + "i", detektionssignale.get(i));
|
nutzerDaten.put(detektionssignale.get(i).getDeviceId() + "i", detektionssignale.get(i));
|
||||||
}
|
}
|
||||||
Log.i(TAG, "addDetektionssignalList: " + nutzerDaten.size());
|
Log.i(TAG, "addDetektionssignalList: " + nutzerDaten.size());
|
||||||
@ -69,6 +68,16 @@ public class Erdbeben {
|
|||||||
}
|
}
|
||||||
epizentrumRechnung.erhoheRadius(berechnungsEndpunkte);
|
epizentrumRechnung.erhoheRadius(berechnungsEndpunkte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Objects.isNull(epizentrumRechnung.trilateration(berechnungsEndpunkte)))
|
||||||
|
{
|
||||||
|
epizentrum = epizentrumRechnung.trilateration(berechnungsEndpunkte);
|
||||||
|
Log.i(TAG, "Koordinaten: " +epizentrum.getKoordinaten().getX() + " " + epizentrum.getKoordinaten().getY());
|
||||||
|
epizentrum.setEntstehungsZeitpunkt(epizentrumRechnung.berechneEntstehungsZeitpunktLongLatt(erstesDetektionssignal, epizentrum.getKoordinaten()));
|
||||||
|
return epizentrum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,18 @@ import android.util.Log;
|
|||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.lemmingapex.trilateration.NonLinearLeastSquaresSolver;
|
||||||
|
import com.lemmingapex.trilateration.TrilaterationFunction;
|
||||||
|
|
||||||
|
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer;
|
||||||
|
import org.apache.commons.math3.fitting.leastsquares.LevenbergMarquardtOptimizer;
|
||||||
|
|
||||||
import de.edotzlaff.detection.detektion.Detektionssignal;
|
import de.edotzlaff.detection.detektion.Detektionssignal;
|
||||||
import de.edotzlaff.detection.detektion.Epizentrum;
|
import de.edotzlaff.detection.detektion.Epizentrum;
|
||||||
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Koordinaten;
|
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Koordinaten;
|
||||||
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Kreis;
|
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Kreis;
|
||||||
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Schnittpunkt;
|
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.Schnittpunkt;
|
||||||
|
import de.edotzlaff.detection.detektion.berechnung.mathObjekte.UTM2Deg;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@ -26,7 +32,7 @@ import java.util.Set;
|
|||||||
public class EpizentrumRechnung {
|
public class EpizentrumRechnung {
|
||||||
|
|
||||||
//ToDo Schrittweite und Abstand auf Szenario anpassen
|
//ToDo Schrittweite und Abstand auf Szenario anpassen
|
||||||
private static final double SCHRITTWEITE = 20;
|
private static final double SCHRITTWEITE = 5;
|
||||||
private static final double MAX_ABSTAND = 5;
|
private static final double MAX_ABSTAND = 5;
|
||||||
private static final int DOUBLESTELLEN = 15;
|
private static final int DOUBLESTELLEN = 15;
|
||||||
private static final int SCHLEIFENDURCHLAUFTE = 5000;
|
private static final int SCHLEIFENDURCHLAUFTE = 5000;
|
||||||
@ -181,21 +187,21 @@ public class EpizentrumRechnung {
|
|||||||
double abstand = Math.sqrt(
|
double abstand = Math.sqrt(
|
||||||
Math.pow(detektionssignal.getKoordinaten().getX() - koordEpi.getX(), 2) +
|
Math.pow(detektionssignal.getKoordinaten().getX() - koordEpi.getX(), 2) +
|
||||||
Math.pow(detektionssignal.getKoordinaten().getY() - koordEpi.getY(), 2));
|
Math.pow(detektionssignal.getKoordinaten().getY() - koordEpi.getY(), 2));
|
||||||
int sec = (int) abstand/ detektionssignal.geschwErdbeben;
|
int sec = (int) (abstand / detektionssignal.geschwErdbeben);
|
||||||
|
|
||||||
return detektionssignal.getAnkunftsZeit().minusSeconds(sec);
|
return detektionssignal.getAnkunftsZeit().minusSeconds(sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
public LocalDateTime berechneEntstehungsZeitpunktLongLatt(Detektionssignal detektionssignal, Koordinaten koordEpi)
|
public LocalDateTime berechneEntstehungsZeitpunktLongLatt(Detektionssignal detektionssignal, Koordinaten koordEpi) {
|
||||||
{
|
|
||||||
float[] results = new float[1];
|
float[] results = new float[1];
|
||||||
Location.distanceBetween(detektionssignal.getKoordinaten().getX(), detektionssignal.getKoordinaten().getY(), koordEpi.getX(), koordEpi.getY(), results);
|
Location.distanceBetween(detektionssignal.getKoordinaten().getX(), detektionssignal.getKoordinaten().getY(), koordEpi.getX(), koordEpi.getY(), results);
|
||||||
float distanceInMeters = results[0];
|
float distanceInMeters = results[0];
|
||||||
int sec = (int) distanceInMeters/ detektionssignal.geschwErdbeben;
|
int sec = (int) (distanceInMeters / detektionssignal.geschwErdbeben);
|
||||||
return detektionssignal.getAnkunftsZeit().minusSeconds(sec);
|
return detektionssignal.getAnkunftsZeit().minusSeconds(sec);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void erhoheRadius(ArrayList<Endpunkt> tempEndpunktListe) {
|
public void erhoheRadius(ArrayList<Endpunkt> tempEndpunktListe) {
|
||||||
|
|
||||||
for (Endpunkt b : tempEndpunktListe) {
|
for (Endpunkt b : tempEndpunktListe) {
|
||||||
@ -203,5 +209,32 @@ public class EpizentrumRechnung {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Epizentrum trilateration(ArrayList<Endpunkt> tempEndpunktListe) {
|
||||||
|
double[][] positions = new double[tempEndpunktListe.size()][2];
|
||||||
|
double[] distances = new double[tempEndpunktListe.size()];
|
||||||
|
|
||||||
|
for (int i = 0; i < tempEndpunktListe.size(); i++) {
|
||||||
|
positions[i][0] = tempEndpunktListe.get(i).getKreis().getMittelPunkt().getX();
|
||||||
|
positions[i][1] = tempEndpunktListe.get(i).getKreis().getMittelPunkt().getY();
|
||||||
|
distances[i] = tempEndpunktListe.get(i).getKreis().getRadius();
|
||||||
|
}
|
||||||
|
NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(new TrilaterationFunction(positions, distances), new LevenbergMarquardtOptimizer());
|
||||||
|
LeastSquaresOptimizer.Optimum optimum = solver.solve();
|
||||||
|
|
||||||
|
double[] centroid = optimum.getPoint().toArray();
|
||||||
|
if (centroid.length == 2) {
|
||||||
|
UTM2Deg utm2Deg = new UTM2Deg();
|
||||||
|
utm2Deg.convertToDeg(32, 'U', centroid[0], centroid[1]);
|
||||||
|
|
||||||
|
Log.i(TAG, "Center: " + utm2Deg.getLatitude() + " " + utm2Deg.getLongitude());
|
||||||
|
Epizentrum epizentrum = new Epizentrum();
|
||||||
|
Koordinaten koordinaten = new Koordinaten(centroid[0], centroid[1]);
|
||||||
|
epizentrum.setKoordinaten(koordinaten);
|
||||||
|
return epizentrum;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user