PC
2024-03-31 608f20e0d5d8f95d9bbb917e95e2913682deb77d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.qianwen.core.tool.metadata.types;
 
import com.alibaba.fastjson.JSON;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import com.qianwen.core.tool.utils.StringPool;
import org.springframework.lang.Nullable;
 
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/metadata/types/GeoPoint.class */
public class GeoPoint implements Serializable {
    private static final long serialVersionUID = -6849794470754667710L;
    private double lon;
    private double lat;
 
    public void setLon(final double lon) {
        this.lon = lon;
    }
 
    public void setLat(final double lat) {
        this.lat = lat;
    }
 
    public GeoPoint(final double lon, final double lat) {
        this.lon = lon;
        this.lat = lat;
    }
 
    public GeoPoint() {
    }
 
    public double getLon() {
        return this.lon;
    }
 
    public double getLat() {
        return this.lat;
    }
 
    public static GeoPoint of(Object val) {
        if (val == null) {
            return null;
        }
        if (val instanceof GeoPoint) {
            return (GeoPoint) val;
        }
        if (val instanceof String) {
            String strVal = String.valueOf(val);
            if (strVal.startsWith(StringPool.LEFT_BRACE)) {
                val = JSON.parseObject(strVal);
            } else if (strVal.startsWith(StringPool.LEFT_SQ_BRACKET)) {
                val = JSON.parseArray(strVal);
            } else {
                val = strVal.split("[,]");
            }
        }
        if (val instanceof Map) {
            Map<Object, Object> mapVal = (Map) val;
            Object lon = mapVal.getOrDefault("lon", mapVal.get("x"));
            Object lat = mapVal.getOrDefault("lat", mapVal.get(StringPool.Y));
            val = new Object[]{lon, lat};
        }
        if (val instanceof Collection) {
            val = ((Collection) val).toArray();
        }
        if (val instanceof Object[]) {
            Object[] arr = (Object[]) val;
            if (arr.length >= 2) {
                return new GeoPoint(new BigDecimal(String.valueOf(arr[0])).doubleValue(), new BigDecimal(String.valueOf(arr[1])).doubleValue());
            }
        }
        throw new IllegalArgumentException("unsupported geo format:" + val);
    }
 
    public int hashCode() {
        long temp = Double.doubleToLongBits(this.lat);
        int result = (31 * 1) + ((int) (temp ^ (temp >>> 32)));
        long temp2 = Double.doubleToLongBits(this.lon);
        return (31 * result) + ((int) (temp2 ^ (temp2 >>> 32)));
    }
 
    public boolean equals(@Nullable Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof GeoPoint)) {
            return false;
        }
        GeoPoint other = (GeoPoint) obj;
        return Double.doubleToLongBits(this.lon) == Double.doubleToLongBits(other.lon) && Double.doubleToLongBits(this.lat) == Double.doubleToLongBits(other.lat);
    }
 
    public String toString() {
        return this.lon + StringPool.COMMA + this.lat;
    }
}