city in coordinates
This commit is contained in:
parent
93bf7e16c1
commit
cbe97329b2
6 changed files with 45 additions and 10 deletions
21
release.properties
Normal file
21
release.properties
Normal file
|
@ -0,0 +1,21 @@
|
|||
#release configuration
|
||||
#Sat Jun 22 12:52:10 CEST 2024
|
||||
completedPhase=check-poms
|
||||
exec.pomFileName=pom.xml
|
||||
exec.snapshotReleasePluginAllowed=false
|
||||
pinExternals=false
|
||||
preparationGoals=clean verify
|
||||
project.scm.eu.m724\:wtapi.developerConnection=scm\:git\:git@git.724.rocks\:Minecon724/wtapi.git
|
||||
project.scm.eu.m724\:wtapi.tag=wtapi-0.5
|
||||
projectVersionPolicyConfig=<projectVersionPolicyConfig>${projectVersionPolicyConfig}</projectVersionPolicyConfig>\n
|
||||
projectVersionPolicyId=default
|
||||
pushChanges=true
|
||||
releaseStrategyId=default
|
||||
remoteTagging=true
|
||||
scm.branchCommitComment=@{prefix} prepare branch @{releaseLabel}
|
||||
scm.commentPrefix=[maven-release-plugin]
|
||||
scm.developmentCommitComment=@{prefix} prepare for next development iteration
|
||||
scm.releaseCommitComment=@{prefix} prepare release @{releaseLabel}
|
||||
scm.rollbackCommitComment=@{prefix} rollback the release of @{releaseLabel}
|
||||
scm.tagNameFormat=@{project.artifactId}-@{project.version}
|
||||
scm.url=scm\:git\:git@git.724.rocks\:Minecon724/wtapi.git
|
|
@ -6,9 +6,20 @@ package eu.m724.wtapi.object;
|
|||
*/
|
||||
public class Coordinates {
|
||||
public double latitude, longitude;
|
||||
public String country, city; // TODO should it stay here?
|
||||
|
||||
public Coordinates(double latitude, double longitude) {
|
||||
this.latitude = (((latitude + 90) % 180) + 180) % 180 - 90;
|
||||
this.longitude = (((longitude + 180) % 360) + 360) % 360 - 180;
|
||||
}
|
||||
|
||||
public Coordinates setAddress(String country, String city) {
|
||||
this.country = country;
|
||||
this.city = city;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return city + ", " + country;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ public class Weather {
|
|||
*/
|
||||
public long sunrise, sunset;
|
||||
|
||||
public String city;
|
||||
|
||||
/**
|
||||
* short name of weather
|
||||
*/
|
||||
|
|
|
@ -167,11 +167,16 @@ public class OWMResponseConverter {
|
|||
break;
|
||||
}
|
||||
|
||||
String city = json.getAsJsonPrimitive("name").getAsString();
|
||||
if (city.equals("Globe") || city.equals("")) city = null;
|
||||
JsonPrimitive countryJson = json.getAsJsonObject("sys").getAsJsonPrimitive("country");
|
||||
String country = countryJson != null ? countryJson.getAsString() : null;
|
||||
|
||||
weather.coordinates =
|
||||
new Coordinates(
|
||||
json.getAsJsonObject("coord").getAsJsonPrimitive("lon").getAsDouble(),
|
||||
json.getAsJsonObject("coord").getAsJsonPrimitive("lat").getAsDouble()
|
||||
);
|
||||
).setAddress(country, city);
|
||||
|
||||
weather.temperature = json
|
||||
.getAsJsonObject("main")
|
||||
|
@ -215,10 +220,6 @@ public class OWMResponseConverter {
|
|||
.getAsJsonPrimitive("sunrise")
|
||||
.getAsLong();
|
||||
|
||||
weather.city = json
|
||||
.getAsJsonPrimitive("name")
|
||||
.getAsString();
|
||||
|
||||
weather.description = json
|
||||
.getAsJsonArray("weather")
|
||||
.get(0).getAsJsonObject()
|
||||
|
|
|
@ -13,6 +13,10 @@ public class CoordinateTest {
|
|||
assert coordinates.longitude == -179.99;
|
||||
|
||||
coordinates = new Coordinates(-91.1, 180.1);
|
||||
assert coordinates.longitude != -179.9; // TODO
|
||||
System.out.printf("Precision loss expected: %f\n", coordinates.longitude);
|
||||
assert coordinates.longitude != -179.9; // TODO fix precision loss
|
||||
|
||||
coordinates.setAddress("SQ", "San Escobar");
|
||||
assert coordinates.getAddress().equals("San Escobar, SQ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class OpenWeatherMapTest {
|
|||
Weather weather = weatherFuture.get();
|
||||
assertNotNull(weather);
|
||||
|
||||
System.out.printf("current weather in %s: %s\n", weather.city, weather.description);
|
||||
System.out.printf("current weather in %s, %s: %s\n", weather.coordinates.city, weather.coordinates.country, weather.description);
|
||||
|
||||
CompletableFuture<Weather[]> weatherBulkFuture =
|
||||
provider.getWeatherBulk(
|
||||
|
@ -41,7 +41,7 @@ public class OpenWeatherMapTest {
|
|||
assert weathers.length == 3;
|
||||
|
||||
for (Weather weather1 : weathers) {
|
||||
System.out.printf("current weather in %s: %s\n", weather1.city, weather1.description);
|
||||
System.out.printf("current weather in %s, %s: %s\n", weather.coordinates.city, weather.coordinates.country, weather1.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue