📄 position.java
字号:
package com.libGPS4j2me;
/**
* This is a class meant for containing positions.
*/
public class Position implements IPosition {
private PositionRadians lat, lon;
/**
* Makes a new position. Initializes the latitude and the longitude to 0.
*/
public Position() {
this(0,0);
}
/**
* Initializes the Position with la as the latitude and lo as the longitude.
*/
public Position(double la, double lo) {
lat = new PositionRadians(la);
lon = new PositionRadians(lo);
}
public Position(PositionRadians la, PositionRadians lo) {
lat = la;
lon = lo;
}
/**
* Initializes the position object from an IPosition reference.
*/
public Position(IPosition pos) {
lat = pos.getLatitude();
lon = pos.getLongitude();
}
/**
* Sets the latitude of this position.
*/
public void setLatitude(PositionRadians l) {
lat = l;
}
/**
* Sets the longitude of this position.
*/
public void setLongitude(PositionRadians l) {
lon = l;
}
/**
* Returns the latitude of this position.
*/
public PositionRadians getLatitude() {
return lat;
}
/**
* Returns the longitude of this position.
*/
public PositionRadians getLongitude() {
return lon;
}
/**
* This method returns the longitude of the position as String.
* No to use here.
*/
public String getLongitudeStr() { return null; }
/**
* This method returns the latitude of the position as String.
* Not to use here.
*/
public String getLatituteStr() {return null; }
public String toString() {
if ( lat == null || lon == null)
return "error printing position packet, long or lat is null";
return "position[" +
String.valueOf(lat.getDegrees()) + "' " + String.valueOf((int)lat.getMinutes())
+ "\" x " + String.valueOf(lon.getDegrees()) + "' " + String.valueOf((int)lon.getMinutes()) + "\"]"
;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -