Compare commits
No commits in common. "76e5ac34f97e3a9257494b1a7afe99d82a9e556a" and "93bf7e16c1945387733d6f6b29341ee4b025165d" have entirely different histories.
76e5ac34f9
...
93bf7e16c1
7 changed files with 12 additions and 47 deletions
4
pom.xml
4
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>wtapi</artifactId>
|
||||
<version>0.7</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@git.724.rocks:Minecon724/wtapi.git</developerConnection>
|
||||
<tag>wtapi-0.7</tag>
|
||||
<tag>wtapi-0.5</tag>
|
||||
</scm>
|
||||
|
||||
</project>
|
|
@ -1,21 +0,0 @@
|
|||
#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,20 +6,9 @@ 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,6 +33,8 @@ public class Weather {
|
|||
*/
|
||||
public long sunrise, sunset;
|
||||
|
||||
public String city;
|
||||
|
||||
/**
|
||||
* short name of weather
|
||||
*/
|
||||
|
|
|
@ -167,16 +167,11 @@ 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")
|
||||
|
@ -220,6 +215,10 @@ public class OWMResponseConverter {
|
|||
.getAsJsonPrimitive("sunrise")
|
||||
.getAsLong();
|
||||
|
||||
weather.city = json
|
||||
.getAsJsonPrimitive("name")
|
||||
.getAsString();
|
||||
|
||||
weather.description = json
|
||||
.getAsJsonArray("weather")
|
||||
.get(0).getAsJsonObject()
|
||||
|
|
|
@ -13,10 +13,6 @@ public class CoordinateTest {
|
|||
assert coordinates.longitude == -179.99;
|
||||
|
||||
coordinates = new Coordinates(-91.1, 180.1);
|
||||
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");
|
||||
assert coordinates.longitude != -179.9; // TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class OpenWeatherMapTest {
|
|||
Weather weather = weatherFuture.get();
|
||||
assertNotNull(weather);
|
||||
|
||||
System.out.printf("current weather in %s, %s: %s\n", weather.coordinates.city, weather.coordinates.country, weather.description);
|
||||
System.out.printf("current weather in %s: %s\n", weather.city, 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: %s\n", weather.coordinates.city, weather.coordinates.country, weather1.description);
|
||||
System.out.printf("current weather in %s: %s\n", weather1.city, weather1.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue