|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void processDataBaseUpdate (DataSnapshot data)
|
|
|
public void processDataBaseUpdate (DataSnapshot data)
|
|
|
{
|
|
|
{
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
//Festellen ob DB oder eigene GPS-Daten verwendet werden sollen
|
|
|
//Festellen ob DB oder eigene GPS-Daten verwendet werden sollen
|
|
|
if(analyzeForUseOfOwnGPS(data))
|
|
|
if(analyzeForUseOfOwnGPS(data))
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
if(analyzeIfAnroidIdIsEmpty(data,f))
|
|
|
if(analyzeIfAnroidIdIsEmpty(data,f))
|
|
|
{
|
|
|
{
|
|
|
String breitengradString = data.child("aron").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
String laengengradString = data.child("aron").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
|
|
|
|
|
|
String breitengradString = data.child("overviewnodes").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
String laengengradString = data.child("overviewnodes").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
breitengrad = Double.parseDouble(breitengradString);
|
|
|
breitengrad = Double.parseDouble(breitengradString);
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
System.out.println("Index: " + f + ": Eintrittskriterien erfüllt.");
|
|
|
System.out.println("Index: " + f + ": Eintrittskriterien erfüllt.");
|
|
|
//Nehme Quelle GPS Daten
|
|
|
//Nehme Quelle GPS Daten
|
|
|
String breitengradString = data.child("aron").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
String laengengradString = data.child("aron").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
|
|
|
|
|
|
String breitengradString = data.child("overviewnodes").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
String laengengradString = data.child("overviewnodes").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
breitengradQuellVibration = breitengradString;
|
|
|
breitengradQuellVibration = breitengradString;
|
|
|
laengengradQuellVibration = laengengradString;
|
|
|
laengengradQuellVibration = laengengradString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//System.out.println("Index: " + f + ": Beide GPS Daten vorhanden. Ich reserviere mir diesen Platz und schreibe hier demnächst rein.");
|
|
|
//System.out.println("Index: " + f + ": Beide GPS Daten vorhanden. Ich reserviere mir diesen Platz und schreibe hier demnächst rein.");
|
|
|
//hier sofort ID eintragen
|
|
|
//hier sofort ID eintragen
|
|
|
//mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
//mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
//mDatenbank.child("aron").child("IDG" + f).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
|
|
|
//mDatenbank.child("overviewnodes").child("IDG" + f).child("a_androidid").setValue(getandroidid());
|
|
|
float distanceToEarthquake;
|
|
|
float distanceToEarthquake;
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
//System.out.println("Index: " + f + ": Diese Slot war leer oder es ist meine eigene ID. Ich schreibe hier rein");
|
|
|
//System.out.println("Index: " + f + ": Diese Slot war leer oder es ist meine eigene ID. Ich schreibe hier rein");
|
|
|
//mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
//mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
//mDatenbank.child("aron").child("IDG" + f).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
|
|
|
//mDatenbank.child("overviewnodes").child("IDG" + f).child("a_androidid").setValue(getandroidid());
|
|
|
float distanceToEarthquake;
|
|
|
float distanceToEarthquake;
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
|
|
|
|
|
|
String nativeGPSString;
|
|
|
String nativeGPSString;
|
|
|
boolean nativeGPS;
|
|
|
boolean nativeGPS;
|
|
|
int amountNativeGPSisTrue = 0;
|
|
|
int amountNativeGPSisTrue = 0;
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
for (int i = 1; i <= indexMax; i++)
|
|
|
for (int i = 1; i <= indexMax; i++)
|
|
|
{
|
|
|
{
|
|
|
nativeGPSString = data.child("aron").child("IDG" + i).child("f_nativegps").getValue().toString();
|
|
|
|
|
|
|
|
|
nativeGPSString = data.child("overviewnodes").child("IDG" + i).child("f_nativegps").getValue().toString();
|
|
|
if(nativeGPSString.equals("true"))
|
|
|
if(nativeGPSString.equals("true"))
|
|
|
{
|
|
|
{
|
|
|
amountNativeGPSisTrue++;
|
|
|
amountNativeGPSisTrue++;
|
|
|
|
|
|
|
|
|
public boolean analyzeIfAnroidIdIsEmpty(DataSnapshot data, int k)
|
|
|
public boolean analyzeIfAnroidIdIsEmpty(DataSnapshot data, int k)
|
|
|
{
|
|
|
{
|
|
|
String androidid;
|
|
|
String androidid;
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
boolean androididempty = false;
|
|
|
boolean androididempty = false;
|
|
|
for (int i = k; i <= k; i++)
|
|
|
for (int i = k; i <= k; i++)
|
|
|
{
|
|
|
{
|
|
|
androidid = data.child("aron").child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
|
|
|
|
|
|
androidid = data.child("overviewnodes").child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
if(androidid.isEmpty())
|
|
|
if(androidid.isEmpty())
|
|
|
{
|
|
|
{
|
|
|
androididempty = true;
|
|
|
androididempty = true;
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
String androididString;
|
|
|
String androididString;
|
|
|
boolean ownAndroidID = false;
|
|
|
boolean ownAndroidID = false;
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
for (int i = k; i <= k; i++)
|
|
|
for (int i = k; i <= k; i++)
|
|
|
{
|
|
|
{
|
|
|
androididString = data.child("aron").child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
|
|
|
|
|
|
androididString = data.child("overviewnodes").child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
if(androididString.equals(getandroidid()))
|
|
|
if(androididString.equals(getandroidid()))
|
|
|
{
|
|
|
{
|
|
|
ownAndroidID = true;
|
|
|
ownAndroidID = true;
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
String vibrationString;
|
|
|
String vibrationString;
|
|
|
boolean stateOfVibration = false;
|
|
|
boolean stateOfVibration = false;
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
for (int i = k; i <= k; i++)
|
|
|
for (int i = k; i <= k; i++)
|
|
|
{
|
|
|
{
|
|
|
vibrationString = data.child("aron").child("IDG" + i).child("g_vibration").getValue().toString();
|
|
|
|
|
|
|
|
|
vibrationString = data.child("overviewnodes").child("IDG" + i).child("g_vibration").getValue().toString();
|
|
|
if(vibrationString.equals("true"))
|
|
|
if(vibrationString.equals("true"))
|
|
|
{
|
|
|
{
|
|
|
stateOfVibration = true;
|
|
|
stateOfVibration = true;
|
|
|
|
|
|
|
|
|
String breitengradString;
|
|
|
String breitengradString;
|
|
|
String laengengradString;
|
|
|
String laengengradString;
|
|
|
boolean bothGPSvaluesExist = false;
|
|
|
boolean bothGPSvaluesExist = false;
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
|
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
for (int i = k; i <= k; i++)
|
|
|
for (int i = k; i <= k; i++)
|
|
|
{
|
|
|
{
|
|
|
breitengradString = data.child("aron").child("IDG" + i).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
laengengradString = data.child("aron").child("IDG" + i).child("e_laengengrad").getValue().toString();
|
|
|
|
|
|
|
|
|
breitengradString = data.child("overviewnodes").child("IDG" + i).child("d_breitengrad").getValue().toString();
|
|
|
|
|
|
laengengradString = data.child("overviewnodes").child("IDG" + i).child("e_laengengrad").getValue().toString();
|
|
|
if(!breitengradString.isEmpty() && !laengengradString.isEmpty())
|
|
|
if(!breitengradString.isEmpty() && !laengengradString.isEmpty())
|
|
|
{
|
|
|
{
|
|
|
bothGPSvaluesExist = true;
|
|
|
bothGPSvaluesExist = true;
|
|
|
|
|
|
|
|
|
public void allocateIDtoDatabaseSlot(int k)
|
|
|
public void allocateIDtoDatabaseSlot(int k)
|
|
|
{
|
|
|
{
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
{
|
|
|
{
|
|
|
System.out.println("Es wird versucht in DB zu schreiben....");
|
|
|
System.out.println("Es wird versucht in DB zu schreiben....");
|
|
|
for(k =k; k<=datenBankSnapShot.child("aron").getChildrenCount();k++)
|
|
|
|
|
|
|
|
|
for(k =k; k<=datenBankSnapShot.child("overviewnodes").getChildrenCount();k++)
|
|
|
{
|
|
|
{
|
|
|
System.out.println("Index...." + k);
|
|
|
System.out.println("Index...." + k);
|
|
|
System.out.println("analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k)" + k + "___" + analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k));
|
|
|
System.out.println("analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k)" + k + "___" + analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k));
|
|
|
|
|
|
|
|
|
System.out.println("Android ID war leer oder es war eigene ID mit Vibration = false. SChreibe in DB...... " + k);
|
|
|
System.out.println("Android ID war leer oder es war eigene ID mit Vibration = false. SChreibe in DB...... " + k);
|
|
|
//Reinschreieben
|
|
|
//Reinschreieben
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
//mDatenbank.child("aron").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now(ZoneOffset.UTC).toString());
|
|
|
|
|
|
|
|
|
//mDatenbank.child("overviewnodes").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now(ZoneOffset.UTC).toString());
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
if (useOwnGPS)
|
|
|
if (useOwnGPS)
|
|
|
{
|
|
|
{
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("f_nativegps").setValue(true);
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("d_breitengrad").setValue(currentLocation.getLatitude()); //aktueller Breitengrad
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude()); //aktueller Längergrad
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("f_nativegps").setValue(true);
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(currentLocation.getLatitude()); //aktueller Breitengrad
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude()); //aktueller Längergrad
|
|
|
}else{
|
|
|
}else{
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("d_breitengrad").setValue(breitengrad); //aktueller Breitengrad
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("e_laengengrad").setValue(laengengrad); //aktueller Längergrad
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("f_nativegps").setValue(false);
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(breitengrad); //aktueller Breitengrad
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(laengengrad); //aktueller Längergrad
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("f_nativegps").setValue(false);
|
|
|
}
|
|
|
}
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("g_vibration").setValue(true);
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis()); //aktueller Zeitstempel wird in Datenbank eingetragen
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("i_amplitude").setValue(1000);
|
|
|
|
|
|
mDatenbank.child("aron").child("IDG" + k).child("w_wellengeschwindigkeit").setValue(db.getMyWaveSpeed());
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("g_vibration").setValue(true);
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis()); //aktueller Zeitstempel wird in Datenbank eingetragen
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("i_amplitude").setValue(1000);
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("w_wellengeschwindigkeit").setValue(db.getMyWaveSpeed());
|
|
|
break;
|
|
|
break;
|
|
|
}else
|
|
|
}else
|
|
|
{
|
|
|
{
|
|
|
System.out.println("Erhöhe Index weil nicht durchgekommen" + k);
|
|
|
System.out.println("Erhöhe Index weil nicht durchgekommen" + k);
|
|
|
//k erhöhen solange leerer Slot ist oder abbruch weil zu voll
|
|
|
//k erhöhen solange leerer Slot ist oder abbruch weil zu voll
|
|
|
if(k ==(int) datenBankSnapShot.child("aron").getChildrenCount())
|
|
|
|
|
|
|
|
|
if(k ==(int) datenBankSnapShot.child("overviewnodes").getChildrenCount())
|
|
|
{
|
|
|
{
|
|
|
System.out.println("Kein freier Slot mehr vorhanden");
|
|
|
System.out.println("Kein freier Slot mehr vorhanden");
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
//####### Auslesen für boolean-Werte #######:
|
|
|
//####### Auslesen für boolean-Werte #######:
|
|
|
int i = 1;
|
|
|
int i = 1;
|
|
|
String vibrationString = data.child("aron").child("IDG").child("vibration").getValue().toString();
|
|
|
|
|
|
String amplitudeString = data.child("aron").child("IDG").child("amplitude").getValue().toString();
|
|
|
|
|
|
|
|
|
String vibrationString = data.child("overviewnodes").child("IDG").child("vibration").getValue().toString();
|
|
|
|
|
|
String amplitudeString = data.child("overviewnodes").child("IDG").child("amplitude").getValue().toString();
|
|
|
boolean vibration;
|
|
|
boolean vibration;
|
|
|
if(vibrationString.equals("true")){
|
|
|
if(vibrationString.equals("true")){
|
|
|
vibration = true;
|
|
|
vibration = true;
|