Skip to content

Commit

Permalink
wp-7 вынесен метод для получения координат
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhin007 committed Jun 26, 2019
1 parent 4f28786 commit 9ff56cf
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.muhin007.iWeatherProvider.weatherAdaptor.helper;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.aerisapi.JSONClass.Response;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.aerisapi.JSONClass.Temp;

import java.io.IOException;

public class Coordinate {

public void getCoordinate(String cityName) {
String request = "https://api.aerisapi.com/forecasts/" + cityName + ",?format=json&filter=day&limit=1&client_id=a04yWLdF5v83ZGGqanosb&client_secret=2moGBj8LBRIlJdhaufg9qCxN7IPLCokJ3OjamuKK";
String result = JSONReadProcess.performRequest(request);
ObjectMapper mapper = new ObjectMapper();
Temp temp = null;
try {
temp = mapper.readValue(result, Temp.class);
} catch (IOException e) {
System.out.println("ошибка чтения данных сайта");
e.printStackTrace();
}
assert temp != null;
for (Response response : temp.getResponse()) {
double lon = response.getLoc().getLong();
double lat = response.getLoc().getLat();
}
}
}

0 comments on commit 9ff56cf

Please sign in to comment.