GPS坐标系转换:点、区域序列化与反序列化、类型处理

This commit is contained in:
attiya 2025-10-21 15:01:38 +08:00
parent 4bef9ce778
commit 2ff0acb9c3
2 changed files with 2 additions and 1 deletions

View File

@ -23,7 +23,7 @@ public class PGpointDeserializer extends JsonDeserializer<PGpoint> {
try {
// 方式1: GeoJSON 格式
if (node.isObject()) {
if (node.isObject() && node.has("type") && "point".equals(node.get("type").asText())) {
JsonNode longitude = node.get("longitude");
JsonNode latitude = node.get("latitude");
if (longitude != null && latitude != null) {

View File

@ -21,6 +21,7 @@ public class PGpointSerializer extends JsonSerializer<PGpoint> {
// 方式1: 序列化为 GeoJSON 格式推荐
gen.writeStartObject();
gen.writeStringField("type","point");
gen.writeNumberField("longitude",point.x);
gen.writeNumberField("latitude",point.x);
// gen.writeArrayFieldStart("coordinates");