|
|
@@ -316,7 +316,7 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
|
|
|
|
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
|
|
|
|
if(analyzeForUseOfOwnGPS(data))
|
|
|
|
{
|
|
|
@@ -335,8 +335,8 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
{
|
|
|
|
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);
|
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
@@ -354,8 +354,8 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
{
|
|
|
|
System.out.println("Index: " + f + ": Eintrittskriterien erfüllt.");
|
|
|
|
//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;
|
|
|
|
laengengradQuellVibration = laengengradString;
|
|
|
|
|
|
|
@@ -371,7 +371,7 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
//System.out.println("Index: " + f + ": Beide GPS Daten vorhanden. Ich reserviere mir diesen Platz und schreibe hier demnächst rein.");
|
|
|
|
//hier sofort ID eintragen
|
|
|
|
//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;
|
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
@@ -398,7 +398,7 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
{
|
|
|
|
//System.out.println("Index: " + f + ": Diese Slot war leer oder es ist meine eigene ID. Ich schreibe hier rein");
|
|
|
|
//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;
|
|
|
|
distanceToEarthquake = distance(currentLocation.getLatitude(), currentLocation.getLongitude(), Double.parseDouble(breitengradQuellVibration), Double.parseDouble(laengengradQuellVibration));
|
|
|
|
long wellenAusbreitungsGeschwindigkeit = (long) db.getMyWaveSpeed(); //Meter die Sekunde
|
|
|
@@ -424,10 +424,10 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
String nativeGPSString;
|
|
|
|
boolean nativeGPS;
|
|
|
|
int amountNativeGPSisTrue = 0;
|
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
|
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"))
|
|
|
|
{
|
|
|
|
amountNativeGPSisTrue++;
|
|
|
@@ -448,11 +448,11 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
public boolean analyzeIfAnroidIdIsEmpty(DataSnapshot data, int k)
|
|
|
|
{
|
|
|
|
String androidid;
|
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
|
boolean androididempty = false;
|
|
|
|
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())
|
|
|
|
{
|
|
|
|
androididempty = true;
|
|
|
@@ -468,10 +468,10 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
{
|
|
|
|
String androididString;
|
|
|
|
boolean ownAndroidID = false;
|
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
|
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()))
|
|
|
|
{
|
|
|
|
ownAndroidID = true;
|
|
|
@@ -487,10 +487,10 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
{
|
|
|
|
String vibrationString;
|
|
|
|
boolean stateOfVibration = false;
|
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
|
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"))
|
|
|
|
{
|
|
|
|
stateOfVibration = true;
|
|
|
@@ -507,11 +507,11 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
String breitengradString;
|
|
|
|
String laengengradString;
|
|
|
|
boolean bothGPSvaluesExist = false;
|
|
|
|
int indexMax = (int) data.child("aron").getChildrenCount();
|
|
|
|
int indexMax = (int) data.child("overviewnodes").getChildrenCount();
|
|
|
|
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())
|
|
|
|
{
|
|
|
|
bothGPSvaluesExist = true;
|
|
|
@@ -526,7 +526,7 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
public void allocateIDtoDatabaseSlot(int k)
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -534,7 +534,7 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
|
{
|
|
|
|
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("analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k)" + k + "___" + analyzeIfAnroidIdIsEmpty(datenBankSnapShot,k));
|
|
|
@@ -547,35 +547,35 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
System.out.println("Android ID war leer oder es war eigene ID mit Vibration = false. SChreibe in DB...... " + k);
|
|
|
|
//Reinschreieben
|
|
|
|
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) {
|
|
|
|
//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)
|
|
|
|
{
|
|
|
|
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{
|
|
|
|
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;
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
System.out.println("Erhöhe Index weil nicht durchgekommen" + k);
|
|
|
|
//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");
|
|
|
|
break;
|
|
|
@@ -621,8 +621,8 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
/*
|
|
|
|
//####### Auslesen für boolean-Werte #######:
|
|
|
|
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;
|
|
|
|
if(vibrationString.equals("true")){
|
|
|
|
vibration = true;
|