package com.tofly.ghrq_route.module.dasData.domain;

import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class DasData {
    private String name;
    @Expose @SerializedName(value = "x")
    private double lng;     //经度
    @Expose @SerializedName(value = "y")
    private double lat;     //维度
    @Expose @SerializedName(value = "z")
    private double alt;     //高度

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getAlt() {
        return alt;
    }

    public void setAlt(double alt) {
        this.alt = alt;
    }

    public static DasData parseDasData(String name, String lngLatAlt) {
        DasData dasData = new DasData();
        dasData.name = name;
        if (lngLatAlt != null && !lngLatAlt.isEmpty()) {
            String[] splits = lngLatAlt.split(",");
            if (splits != null) {
                String strLng = splits[0];
                if (strLng != null) {
                    dasData.lng = Double.parseDouble(strLng);
                }
                String strLat = splits[1];
                if (strLat != null) {
                    dasData.lat = Double.parseDouble(strLat);
                }
                String strAlt = splits[2];
                if (strAlt != null) {
                    dasData.alt = Double.parseDouble(strAlt);
                }
            }
        }
        return dasData;
    }

    public Point getGeometry(SpatialReference sp) {
        Point point = new Point(lng, lat, sp);
        return point;
    }
}
