diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/geo/GeoType.java b/blade-core-tool/src/main/java/org/springblade/core/tool/geo/GeoType.java index 81339c9..db773a3 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/geo/GeoType.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/geo/GeoType.java @@ -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); + } + }