From 5ac928701562b0a3803bd520ede7fa74addd84c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Wed, 6 Nov 2024 11:18:40 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BB=A3=E7=A0=81=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/core/tool/geo/GeoType.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); + } + }