Skip to content

Commit

Permalink
✨ 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xunhuan committed Nov 6, 2024
1 parent 6ef35f5 commit fc06dea
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package net.dreamlu.mica.core.geo;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -99,6 +101,7 @@ public GeoPoint toBD09(double lon, double lat) {
}
};

@JsonValue
private final String type;
private final String desc;

Expand Down Expand Up @@ -129,4 +132,21 @@ public GeoPoint toBD09(double lon, double lat) {
*/
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);
}

}

0 comments on commit fc06dea

Please sign in to comment.