添加中央气象台地面气象预警数据源
parent
4520c5c24d
commit
443a226fd7
@ -0,0 +1,32 @@
|
|||||||
|
package com.htfp.weather.web.pojo.cma;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddressComponent {
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
private String city;
|
||||||
|
@JsonProperty("county_code")
|
||||||
|
private String countyCode;
|
||||||
|
private String nation;
|
||||||
|
@JsonProperty("poi_position")
|
||||||
|
private String poiPosition;
|
||||||
|
private String county;
|
||||||
|
@JsonProperty("city_code")
|
||||||
|
private String cityCode;
|
||||||
|
@JsonProperty("address_position")
|
||||||
|
private String addressPosition;
|
||||||
|
private String poi;
|
||||||
|
@JsonProperty("province_code")
|
||||||
|
private String provinceCode;
|
||||||
|
private String province;
|
||||||
|
private String road;
|
||||||
|
@JsonProperty("road_distance")
|
||||||
|
private int roadDistance;
|
||||||
|
@JsonProperty("poi_distance")
|
||||||
|
private int poiDistance;
|
||||||
|
@JsonProperty("address_distance")
|
||||||
|
private int addressDistance;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.htfp.weather.web.pojo.cma;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author : shiyi
|
||||||
|
* @Date : 2024/7/2 16:13
|
||||||
|
* @Description : 天地图逆编码响应结构
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AntiGeoCodeResponse {
|
||||||
|
Result result;
|
||||||
|
String msg;
|
||||||
|
String status;
|
||||||
|
@Data @JsonIgnoreProperties(value = {"formattedAddress", "location"}, ignoreUnknown = true)
|
||||||
|
public static class Result {
|
||||||
|
AddressComponent addressComponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.htfp.weather.web.service.surfaceapi;
|
||||||
|
|
||||||
|
import com.htfp.weather.web.exception.AppException;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author : shiyi
|
||||||
|
* @Date : 2024/7/2 16:43
|
||||||
|
* @Description :
|
||||||
|
*/
|
||||||
|
@SpringBootTest
|
||||||
|
class CmaServiceImplTest {
|
||||||
|
@Resource
|
||||||
|
CmaServiceImpl cmaService;
|
||||||
|
@Test
|
||||||
|
void normalTest() throws Exception {
|
||||||
|
String countyIdByLatLon = cmaService.getCountyIdByLatLon(39.9042, 116.4073);
|
||||||
|
Assertions.assertEquals("110101", countyIdByLatLon);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void outOfRange() throws Exception {
|
||||||
|
cmaService.getCountyIdByLatLon(39.9042, 166.4073);
|
||||||
|
Assertions.assertThrows(AppException.class, () -> {
|
||||||
|
cmaService.getCountyIdByLatLon(39.9042, 166.4073);
|
||||||
|
});
|
||||||
|
Assertions.assertThrows(AppException.class, () -> {
|
||||||
|
cmaService.getCountyIdByLatLon(139.9042, 166.4073);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void updateCmaWarning() throws Exception {
|
||||||
|
cmaService.updateCmaWarning();
|
||||||
|
System.out.println(cmaService.getSurfaceWarningByCounty("310000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getWarningByLocation() throws Exception {
|
||||||
|
System.out.println(cmaService.getSurfaceWarning(41.22, 123.07));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue