代码完善

This commit is contained in:
卢春梦 2024-11-06 11:18:40 +08:00
parent 6e7246a44d
commit 5ac9287015

View File

@ -16,6 +16,8 @@
package org.springblade.core.tool.geo;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@ -99,6 +101,7 @@ public enum GeoType {
}
};
@JsonValue
private final String type;
private final String desc;
@ -129,4 +132,20 @@ public enum GeoType {
*/
public abstract GeoPoint toBD09(double lon, double lat);
/**
* 获取坐标系
*
* @param type type 坐标系类型
* @return GeoType
*/
@JsonCreator
public static GeoType getGeoType(String type) {
for (GeoType geoType : values()) {
if (geoType.type.equalsIgnoreCase(type)) {
return geoType;
}
}
throw new IllegalArgumentException("未知的坐标系类型" + type);
}
}