positionradians.java

来自「A Java Framework for connecting to and e」· Java 代码 · 共 72 行

JAVA
72
字号
package com.libGPS4j2me;

/**
* Class used to store radians, usually latitude or longitude.
* Contains methods for converting to the format degress,minutes.
*/ 
public class PositionRadians {
	private final double value;
	
	/**
	* Initializes the PositionRadians-object. After the object is constructed, it can't change is value.
	*/
	public PositionRadians(double v) {
		value = v;
	}
	
	public double getRadians() {
		return value;
	}

	/**
	* Returns the degrees part of this object, when converted to coordinates.
	*/		
	public int getDegrees() {
		return (int) (value * (180.0d / Math.PI));
	}
	
	/**
	* Returns the minutes part of this object, when converted to coordinates.
	*/	
	public double getMinutes() {
		double v = value * (180.0d / Math.PI);
		v -= getDegrees();
		return 60 * v; // 60 minutes in one degree.
	}

	
	/** 
	* Tests if the two PositionRadians contains the same value.
	*/ 
	public boolean equals(PositionRadians p) {
		if (value == p.value)
			return true;
		else
			return false;
	}
	
	/**
	* Tests if this PositionRadians is greater than p.
	*/	
	public boolean greaterThan(PositionRadians p) {
		if (value > p.value) 
			return true;
		else
			return false;
	}
	
	/**
	* Tests if this PositionRadians is smaller than p.	 
	*/ 
	
	public boolean smallerThan(PositionRadians p) {
		if (value < p.value) 
			return true;
		else
			return false;
	}	
	
	public String toString() {
		return String.valueOf(getDegrees()) + "\' " + String.valueOf((int)getMinutes()) + "\"";
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?