fix: weather data test
This commit is contained in:
parent
79a3e1941a
commit
a41df4b124
@ -1,6 +1,8 @@
|
|||||||
package eirb.pg203.weather.data;
|
package eirb.pg203.weather.data;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import eirb.pg203.weather.utils.City;
|
import eirb.pg203.weather.utils.City;
|
||||||
@ -93,7 +95,7 @@ public class WeatherData {
|
|||||||
|
|
||||||
|
|
||||||
private WindDirection getWindDirection(float windDirectionAngle) {
|
private WindDirection getWindDirection(float windDirectionAngle) {
|
||||||
if (windDirectionAngle >= 337.5 || windDirectionAngle <= 22.5)
|
if ((windDirectionAngle >= 337.5 && windDirectionAngle <= 360) || (windDirectionAngle >= 0 && windDirectionAngle <= 22.5))
|
||||||
return WindDirection.N;
|
return WindDirection.N;
|
||||||
if (windDirectionAngle > 22.5 && windDirectionAngle <= 67.5)
|
if (windDirectionAngle > 22.5 && windDirectionAngle <= 67.5)
|
||||||
return WindDirection.NE;
|
return WindDirection.NE;
|
||||||
@ -172,11 +174,12 @@ public class WeatherData {
|
|||||||
|
|
||||||
public void setWindDirectionAngle(float windDirectionAngle) {
|
public void setWindDirectionAngle(float windDirectionAngle) {
|
||||||
this.windDirectionAngle = windDirectionAngle;
|
this.windDirectionAngle = windDirectionAngle;
|
||||||
|
this.windDirection = this.getWindDirection(windDirectionAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%05.2f° %s %05.2fkm/h %06.2f° %s",
|
return String.format(Locale.ENGLISH, "%05.2f° %s %05.2fkm/h %06.2f° %s",
|
||||||
this.getTemp(),
|
this.getTemp(),
|
||||||
this.getCondition().toString(),
|
this.getCondition().toString(),
|
||||||
this.getWindSpeed(),
|
this.getWindSpeed(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user