接收的火点数据使用高德api格式化位置信息

This commit is contained in:
liuchengqian 2022-06-27 10:23:55 +08:00
parent 5550177277
commit bbb5347967
3 changed files with 126 additions and 81 deletions

View File

@ -3,9 +3,6 @@ package com.xkrs.model.entity;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
/**
* @author XinYi Song
*/
@Entity @Entity
@Table(name = "fire_point") @Table(name = "fire_point")
public class FirePointEntity implements Serializable { public class FirePointEntity implements Serializable {
@ -35,37 +32,57 @@ public class FirePointEntity implements Serializable {
private double latitude; private double latitude;
/** /**
* 省市区的编码 * 详细地址
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String firePointAddress;
/**
* 街道编码
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String streetCode;
/**
* 街道名称
*/
@Column(length = 85, columnDefinition = "varchar(85)")
private String streetName;
/**
* 省市区编码
*/ */
@Column(length = 32, columnDefinition = "varchar(32)") @Column(length = 32, columnDefinition = "varchar(32)")
private String countyCode; private String countyCode;
/** /**
* 省市区的名称 * 省市区名称
*/ */
@Column(columnDefinition = "varchar(64)") @Column(length = 64, columnDefinition = "varchar(64)")
private String countyName; private String countyName;
/** /**
* 卫星监测的时间 * 卫星监测的时间
*/ */
@Column(length = 64, columnDefinition = "varchar(64)")
private String satelliteTime; private String satelliteTime;
/** /**
* 卫星的类型 * 卫星的类型
*/ */
@Column(columnDefinition = "varchar(64)") @Column(length = 64, columnDefinition = "varchar(64)")
private String satelliteType; private String satelliteType;
/** /**
* 植被类型 * 植被类型
*/ */
@Column(columnDefinition = "varchar(64)") @Column(length = 64, columnDefinition = "varchar(64)")
private String landType; private String landType;
/** /**
* 添加的时间 * 添加的时间
*/ */
@Column(length = 64, columnDefinition = "varchar(64)")
private String addTime; private String addTime;
/** /**
@ -75,54 +92,48 @@ public class FirePointEntity implements Serializable {
private String confidence; private String confidence;
/** /**
* 详细地址 * 火点状态
*/ * 0发现
private String firePointAddress; * 1预警
* 2核查
/** * -13结案
* 火点状态 0 发现 1预警 2核查 -1,3结案
*/ */
@Column(length = 32, columnDefinition = "varchar(32)") @Column(length = 32, columnDefinition = "varchar(32)")
private String fireType; private String fireType;
/**
* 当前火点的图片
*/
private String fireImage;
/**
* 卫星影像图片
*/
private String satelliteImage;
/**
* 火点前的图片
*/
private String beforeFireImage;
/**
* 火点后的图片
*/
private String afterFireImage;
/**
* 街道编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String streetCode;
@Column(length = 65, columnDefinition = "varchar(85)")
private String streetName;
/** /**
* 审核火点状态 * 审核火点状态
* 0未审核 * 0未审核
* 1审核通过 * 1审核通过
* 2审核未通过 * 2审核未通过
*/ */
@Column(length = 65, columnDefinition = "varchar(85)") @Column(length = 65, columnDefinition = "varchar(32)")
private String auditFireType; private String auditFireType;
/**
* 当前火点的图片
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String fireImage;
/**
* 卫星影像图片
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String satelliteImage;
/**
* 火点前的图片
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String beforeFireImage;
/**
* 火点后的图片
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String afterFireImage;
public FirePointEntity() { public FirePointEntity() {
} }
@ -158,6 +169,30 @@ public class FirePointEntity implements Serializable {
this.latitude = latitude; this.latitude = latitude;
} }
public String getFirePointAddress() {
return firePointAddress;
}
public void setFirePointAddress(String firePointAddress) {
this.firePointAddress = firePointAddress;
}
public String getStreetCode() {
return streetCode;
}
public void setStreetCode(String streetCode) {
this.streetCode = streetCode;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getCountyCode() { public String getCountyCode() {
return countyCode; return countyCode;
} }
@ -214,14 +249,6 @@ public class FirePointEntity implements Serializable {
this.confidence = confidence; this.confidence = confidence;
} }
public String getFirePointAddress() {
return firePointAddress;
}
public void setFirePointAddress(String firePointAddress) {
this.firePointAddress = firePointAddress;
}
public String getFireType() { public String getFireType() {
return fireType; return fireType;
} }
@ -230,6 +257,14 @@ public class FirePointEntity implements Serializable {
this.fireType = fireType; this.fireType = fireType;
} }
public String getAuditFireType() {
return auditFireType;
}
public void setAuditFireType(String auditFireType) {
this.auditFireType = auditFireType;
}
public String getFireImage() { public String getFireImage() {
return fireImage; return fireImage;
} }
@ -262,32 +297,29 @@ public class FirePointEntity implements Serializable {
this.afterFireImage = afterFireImage; this.afterFireImage = afterFireImage;
} }
public String getStreetCode() {
return streetCode;
}
public void setStreetCode(String streetCode) {
this.streetCode = streetCode;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getAuditFireType() {
return auditFireType;
}
public void setAuditFireType(String auditFireType) {
this.auditFireType = auditFireType;
}
@Override @Override
public String toString() { public String toString() {
return "FirePointEntity{" + "id=" + id + ", fireCode='" + fireCode + '\'' + ", longitude=" + longitude + ", latitude=" + latitude + ", countyCode='" + countyCode + '\'' + ", countyName='" + countyName + '\'' + ", satelliteTime='" + satelliteTime + '\'' + ", satelliteType='" + satelliteType + '\'' + ", landType='" + landType + '\'' + ", addTime='" + addTime + '\'' + ", confidence='" + confidence + '\'' + ", firePointAddress='" + firePointAddress + '\'' + ", fireType='" + fireType + '\'' + ", fireImage='" + fireImage + '\'' + ", satelliteImage='" + satelliteImage + '\'' + ", beforeFireImage='" + beforeFireImage + '\'' + ", afterFireImage='" + afterFireImage + '\'' + ", streetCode='" + streetCode + '\'' + ", streetName='" + streetName + '\'' + ", auditFireType='" + auditFireType + '\'' + '}'; return "FirePointEntity{" +
"id=" + id +
", fireCode='" + fireCode + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", firePointAddress='" + firePointAddress + '\'' +
", streetCode='" + streetCode + '\'' +
", streetName='" + streetName + '\'' +
", countyCode='" + countyCode + '\'' +
", countyName='" + countyName + '\'' +
", satelliteTime='" + satelliteTime + '\'' +
", satelliteType='" + satelliteType + '\'' +
", landType='" + landType + '\'' +
", addTime='" + addTime + '\'' +
", confidence='" + confidence + '\'' +
", fireType='" + fireType + '\'' +
", auditFireType='" + auditFireType + '\'' +
", fireImage='" + fireImage + '\'' +
", satelliteImage='" + satelliteImage + '\'' +
", beforeFireImage='" + beforeFireImage + '\'' +
", afterFireImage='" + afterFireImage + '\'' +
'}';
} }
} }

View File

@ -270,11 +270,12 @@ public class FirePointServiceImpl implements FirePointService {
String formattedAddress = reGeoCode.getFormatted_address(); String formattedAddress = reGeoCode.getFormatted_address();
firePointEntity.setFirePointAddress(formattedAddress); firePointEntity.setFirePointAddress(formattedAddress);
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0); GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
firePointEntity.setCountyCode(addressComponent.getAdcode());
firePointEntity.setCountyName(addressComponent.getDistrict());
String townCode = addressComponent.getTowncode(); String townCode = addressComponent.getTowncode();
String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode; String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode;
firePointEntity.setStreetCode(fixedTownCode); firePointEntity.setStreetCode(fixedTownCode);
String townShip = addressComponent.getTownship(); firePointEntity.setStreetName(addressComponent.getTownship());
firePointEntity.setStreetName(townShip);
} }
/** /**
@ -288,11 +289,12 @@ public class FirePointServiceImpl implements FirePointService {
String formattedAddress = reGeoCode.getFormatted_address(); String formattedAddress = reGeoCode.getFormatted_address();
firePointEntity.setFirePointAddress(formattedAddress); firePointEntity.setFirePointAddress(formattedAddress);
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0); GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
firePointEntity.setCountyCode(addressComponent.getAdcode());
firePointEntity.setCountyName(addressComponent.getDistrict());
String townCode = addressComponent.getTowncode(); String townCode = addressComponent.getTowncode();
String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode; String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode;
firePointEntity.setStreetCode(fixedTownCode); firePointEntity.setStreetCode(fixedTownCode);
String townShip = addressComponent.getTownship(); firePointEntity.setStreetName(addressComponent.getTownship());
firePointEntity.setStreetName(townShip);
} }
/** /**

View File

@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_KEY; import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_KEY;
@ -52,4 +53,14 @@ public class GaoDeApiUtil {
}}; }};
} }
public static void main(String[] args) {
List<String> location = new ArrayList<>();
location.add("120,36");
GaoDeIgGeocodeVo geocode = geocode(location);
System.out.println("sdfghjm");
}
} }