displaying windspeed either in m/s and knots

fix/get-all-stations-hangout
Mateusz Lubecki 2021-11-25 21:56:02 +01:00
rodzic bbd4657946
commit f19b196aac
8 zmienionych plików z 120 dodań i 69 usunięć

Wyświetl plik

@ -87,10 +87,10 @@ public class FavouritesStationDetailsUpdater implements Runnable {
// check if station transmits humidity
if (summary.humidity_qf_native.equals(QualityFactor.FULL) || summary.humidity_qf_native.equals(QualityFactor.DEGRADED)) {
str = String.format("%d°C %d%% %s %3.1f m/s max %3.1f m/s", Math.round(summary.avg_temperature), summary.humidity, summary.getWindDirStr(), summary.average_speed, summary.gusts);
str = String.format("%d°C %d%% %s %s max %s", Math.round(summary.avg_temperature), summary.humidity, summary.getWindDirStr(), summary.getWindspeedStr(), summary.getWindgustsStr());
}
else {
str = String.format("%d°C %s %3.1f m/s max %3.1f m/s", Math.round(summary.avg_temperature), summary.getWindDirStr(), summary.average_speed, summary.gusts);
str = String.format("%d°C %s %s max %s", Math.round(summary.avg_temperature), summary.getWindDirStr(), summary.getWindspeedStr(), summary.getWindgustsStr());
}
}
else {

Wyświetl plik

@ -119,32 +119,6 @@ public class WeatherStationRecyclerViewAdapter extends RecyclerView.Adapter<AllS
if (textViewData != null && favsUpdater != null) {
favsUpdater.addNewStation(station.getSystemName(), textViewData);
// // in Favorites view there is 'textViewData' which displays measurements in each entry
//
// Summary summary = summaryDao.getStationSummary(station.getSystemName());
//
// if (summary != null) {
// String str;
// if (summary.wind_qf_native.equals(QualityFactor.FULL) || summary.wind_qf_native.equals(QualityFactor.DEGRADED)) {
// if (summary.humidity_qf_native.equals(QualityFactor.FULL) || summary.humidity_qf_native.equals(QualityFactor.DEGRADED)) {
// str = String.format("%d°C %d%% %s %3.1f m/s max %3.1f m/s", Math.round(summary.avg_temperature), summary.humidity, summary.getWindDirStr(), summary.average_speed, summary.gusts);
// }
// else {
// str = String.format("%d°C %s %3.1f m/s max %3.1f m/s", Math.round(summary.avg_temperature), summary.getWindDirStr(), summary.average_speed, summary.gusts);
// }
// }
// else {
// if (summary.humidity_qf_native.equals(QualityFactor.FULL) || summary.humidity_qf_native.equals(QualityFactor.DEGRADED)) {
// str = String.format("%d°C %d%%", Math.round(summary.avg_temperature), summary.humidity);
// }
// else {
// str = String.format("%d°C", Math.round(summary.avg_temperature));
//
// }
// }
//
// textViewData.setText(str);
// }
}
}

Wyświetl plik

@ -109,14 +109,14 @@ public class StationSummaryActElements implements StationActivityElements {
}
if (!s.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.windSpeed) {
wind_speed_val.setText(String.format("%.1f m/s", s.average_speed));
wind_speed_val.setText(String.format("%s", s.getWindspeedStr()));
}
else {
wind_speed_val.setText("---");
}
if (!s.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.windGusts) {
wind_gusts_val.setText(String.format("%.1f m/s", s.gusts));
wind_gusts_val.setText(String.format("%s", s.getWindgustsStr()));
}
else {
wind_gusts_val.setText("---");

Wyświetl plik

@ -94,8 +94,8 @@ public class StationWindRoseActElements implements StationActivityElements {
}
// create strings with wind speed, gusts etc
String average_speed = String.format("%3.1f", data.average_speed);
String gusts_speed = String.format("%3.1f", data.gusts);
String average_speed = String.format("%s", data.getWindspeedStr());
String gusts_speed = String.format("%s", data.getWindgustsStr());
// check if wind data is avaliable in the input data set
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
@ -107,13 +107,13 @@ public class StationWindRoseActElements implements StationActivityElements {
}
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + average_speed + "m/s");
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + average_speed);
} else {
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + "---");
}
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + gusts_speed + "m/s");
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + gusts_speed);
} else {
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + "---");
@ -133,12 +133,12 @@ public class StationWindRoseActElements implements StationActivityElements {
}
if (!no_data && !old_data) {
String hour_max_gusts = String.format("%3.1f", data.hour_gusts);
String hour_min_avg = String.format("%3.1f", data.hour_min_average_speed);
String hour_max_gusts = String.format("%s", data.getHourWindgustsStr());
String hour_min_avg = String.format("%s", data.getHourMinWindspeedStr());
pressure.setText(activity.getResources().getString(R.string.qnh) + ": " + String.format("%d hPa", data.qnh));
maxGust.setText(activity.getResources().getString(R.string.max_1h_gust) + ": " + hour_max_gusts + "m/s");
minAverage.setText(activity.getResources().getString(R.string.min_1h_avg) + ": " + hour_min_avg + "m/s");
maxGust.setText(activity.getResources().getString(R.string.max_1h_gust) + ": " + hour_max_gusts);
minAverage.setText(activity.getResources().getString(R.string.min_1h_avg) + ": " + hour_min_avg);
} else if (!no_data && old_data) {
maxGust.setText(activity.getResources().getString(R.string.warning));
maxGust.setTextColor(Color.RED);

Wyświetl plik

@ -1,5 +1,7 @@
package cc.pogoda.mobile.pogodacc.type.web;
import cc.pogoda.mobile.pogodacc.config.AppConfiguration;
public class Summary {
public long last_timestamp;
@ -26,15 +28,15 @@ public class Summary {
public short direction;
public float average_speed;
private float average_speed;
public float gusts;
private float gusts;
public float hour_gusts;
private float hour_gusts;
public float hour_max_average_speed;
private float hour_max_average_speed;
public float hour_min_average_speed;
private float hour_min_average_speed;
public String wind_qf;
@ -46,6 +48,81 @@ public class Summary {
wind_qf_native = QualityFactor.UNSET;
}
public String getWindspeedStr() {
String out;
if (AppConfiguration.replaceMsWithKnots) {
float knots = this.average_speed * 1.94f;
out = String.format("%2d kn", Math.round(knots));
}
else {
out = String.format("%4.1fm/s", this.average_speed);
}
return out;
}
public String getHourMinWindspeedStr() {
String out;
if (AppConfiguration.replaceMsWithKnots) {
float knots = this.hour_min_average_speed * 1.94f;
out = String.format("%2d kn", Math.round(knots));
}
else {
out = String.format("%4.1fm/s", this.hour_min_average_speed);
}
return out;
}
public String getHourMaxWindspeedStr() {
String out;
if (AppConfiguration.replaceMsWithKnots) {
float knots = this.hour_max_average_speed * 1.94f;
out = String.format("%2d kn", Math.round(knots));
}
else {
out = String.format("%4.1fm/s", this.hour_max_average_speed);
}
return out;
}
public String getWindgustsStr() {
String out;
if (AppConfiguration.replaceMsWithKnots) {
float knots = this.gusts * 1.94f;
out = String.format("%2d kn", Math.round(knots));
}
else {
out = String.format("%4.1fm/s", this.gusts);
}
return out;
}
public String getHourWindgustsStr() {
String out;
if (AppConfiguration.replaceMsWithKnots) {
float knots = this.hour_gusts * 1.94f;
out = String.format("%2d kn", Math.round(knots));
}
else {
out = String.format("%4.1fm/s", this.hour_gusts);
}
return out;
}
public String getWindDirStr() {
String out;

Wyświetl plik

@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
android:text="---"
android:textSize="38sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -37,7 +37,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"

Wyświetl plik

@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
android:text="---"
android:textSize="38sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -37,7 +37,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
@ -64,7 +64,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="30sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendCurrentHValue"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTLabel"
@ -78,7 +78,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="30sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendHLabel"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendCurrentTValue"
@ -102,7 +102,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendTwoHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -115,7 +115,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTwoHoursTValue"
@ -139,7 +139,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendFourHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -152,7 +152,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendFourHoursTValue"
@ -176,7 +176,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendSixHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -189,7 +189,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendSixHoursTValue"
@ -213,7 +213,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendEightHoursHVal"
app:layout_constraintStart_toStartOf="parent"
@ -226,7 +226,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTrendEightHoursTVal"

Wyświetl plik

@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
android:text="---"
android:textSize="38sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -37,7 +37,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
@ -64,7 +64,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="30sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendCurrentHValue"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTLabel"
@ -78,7 +78,7 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="30sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendHLabel"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendCurrentTValue"
@ -102,7 +102,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendTwoHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -115,7 +115,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTwoHoursTValue"
@ -139,7 +139,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendFourHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -152,7 +152,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendFourHoursTValue"
@ -176,7 +176,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendSixHoursHValue"
app:layout_constraintStart_toStartOf="parent"
@ -189,7 +189,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendSixHoursTValue"
@ -213,7 +213,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/textViewTemperatureTrendEightHoursHVal"
app:layout_constraintStart_toStartOf="parent"
@ -226,7 +226,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:text="---"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textViewTemperatureTrendTrendEightHoursTVal"