All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nervousync.beans.location.GeoPoint Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.nervousync.beans.location;

import java.io.Serializable;


/**
 * 

Geography point define

*

地理位置信息定义

* * @author Steven Wee [email protected] * @version $Revision: 1.1.1 $ $Date: Sep 09, 2022 13:03:40 $ */ public final class GeoPoint implements Serializable { /** * Serial version UID * 序列化UID */ private static final long serialVersionUID = -3501428042311016856L; /** * Enumeration value of GeoPoint.LocationType * 地理坐标类型枚举值 * @see GeoPoint.LocationType */ private final LocationType locationType; /** * Longitude value of GeoPoint * 地理坐标经度值 */ private final double longitude; /** * Latitude value of GeoPoint * 地理坐标纬度值 */ private final double latitude; /** *

Constructor for GeoPoint

*

GeoPoint默认构造方法

* * @param locationType Enumeration value of GeoPoint.LocationType * 地理坐标类型枚举值 * @param longitude Longitude value of GeoPoint * 地理坐标经度值 * @param latitude Latitude value of GeoPoint * 地理坐标纬度值 */ private GeoPoint(final LocationType locationType, final double longitude, final double latitude) { this.locationType = locationType; this.longitude = longitude; this.latitude = latitude; } /** *

Static method for initialize GPS GeoPoint by given location (longitude, latitude)

*

用于初始化GPS地理坐标的静态方法,使用给定的坐标(longitude,latitude)

* * @param longitude Longitude value of GeoPoint * 地理坐标经度值 * @param latitude Latitude value of GeoPoint * 地理坐标纬度值 * @return Initialized GeoPoint instance * 初始化的GeoPoint实例对象 */ public static GeoPoint gpsPoint(final double longitude, final double latitude) { return new GeoPoint(LocationType.GPS, longitude, latitude); } /** *

Static method for initialize GCJ02 GeoPoint by given location (longitude, latitude)

*

用于初始化GCJ02地理坐标的静态方法,使用给定的坐标(longitude,latitude)

* * @param longitude Longitude value of GeoPoint * 地理坐标经度值 * @param latitude Latitude value of GeoPoint * 地理坐标纬度值 * @return Initialized GeoPoint instance * 初始化的GeoPoint实例对象 */ public static GeoPoint gcj02Point(final double longitude, final double latitude) { return new GeoPoint(LocationType.GCJ_02, longitude, latitude); } /** *

Static method for initialize BD09 GeoPoint by given location (longitude, latitude)

*

用于初始化BD09地理坐标的静态方法,使用给定的坐标(longitude,latitude)

* * @param longitude Longitude value of GeoPoint * 地理坐标经度值 * @param latitude Latitude value of GeoPoint * 地理坐标纬度值 * @return Initialized GeoPoint instance * 初始化的GeoPoint实例对象 */ public static GeoPoint bd09Point(final double longitude, final double latitude) { return new GeoPoint(LocationType.BD_09, longitude, latitude); } /** *

Static method for initialize Delta GeoPoint by given location (longitude, latitude)

*

用于初始化Delta地理坐标的静态方法,使用给定的坐标(longitude,latitude)

* * @param longitude Longitude value of GeoPoint * 地理坐标经度值 * @param latitude Latitude value of GeoPoint * 地理坐标纬度值 * @return Initialized GeoPoint instance * 初始化的GeoPoint实例对象 */ public static GeoPoint deltaPoint(final double longitude, final double latitude) { return new GeoPoint(LocationType.DELTA, longitude, latitude); } /** *

Getter method for location type

*

坐标类型的Getter方法

* * @return Value of location type * 坐标类型值 */ public LocationType getLocationType() { return locationType; } /** *

Getter method for location longitude

*

坐标经度值的Getter方法

* * @return Value of location longitude * 坐标经度值 */ public double getLongitude() { return longitude; } /** *

Getter method for location latitude

*

坐标纬度值的Getter方法

* * @return Value of location latitude * 坐标纬度值 */ public double getLatitude() { return latitude; } /** *

Override method for toString

*

* Join longitude and latitude using split character: ", ", * longitude value is before the split character, latitude value is after the split character *

*

覆写的toString方法

* * @return Value of location latitude * 坐标纬度值 */ @Override public String toString() { if (LocationType.GPS.equals(this.locationType)) { return this.latitude + "," + this.longitude; } return this.longitude + "," + this.latitude; } /** *

Enumeration define for LocationType

*

LocationType枚举类定义

*/ public enum LocationType { /** * GPS/WGS84 Record * GPS/WGS84坐标 */ GPS, /** * GCJ-02 Record * GCJ-02坐标 */ GCJ_02, /** * BD-09 Record * GCJ02坐标 */ BD_09, /** * DELTA Record, using for convert between the location types * DELTA坐标,用于不同坐标系间的数据转换 */ DELTA } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy