📄 elementtowpt.java
字号:
package net.aetherial.gis.dataType;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ElementToWpt {
public String txt = "";
public ElementToWpt() {
}
public void setHead(){
txt = txt +"H SOFTWARE NAME & VERSION\r\n";
txt = txt +"I PCX5 2.08\r\n";
txt = txt +"\r\n";
txt = txt +"H R DATUM IDX DA DF DX DY DZ\r\n";
txt = txt +"M G WGS 84 121 +0.000000e+00 +0.000000e+00 +0.000000e+00 +0.000000e+00 +0.000000e+00\r\n";
txt = txt +"\r\n";
txt = txt +"H COORDINATE SYSTEM\r\n";
txt = txt +"U LAT LON DM\r\n";
txt = txt +"\r\n";
txt = txt +"H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\r\n";
}
public String setNameToGPSMap(String wptName){
wptName = wptName.trim();
wptName = wptName.replace('(','(');
wptName = wptName.replace(')',')');
wptName = wptName.replace('/','-');
wptName = wptName.replace('\\','-');
wptName = wptName.replaceAll("--","-");
return wptName;
}
public void appendWpt(String wptName,String N,String E,String altitude,String time){
//wptName = this.setNameToGPSMap(wptName);
String lat = N + "";
String lon = E + "";
String alt = altitude + "";
int pos = 0;
System.out.println("lat:" + lat + ",lon" + lon + " --Class ElementToWPT");
////////////////////////////
int llen = lat.length();
if (llen < 10) {
lat = Double.parseDouble(lat) * 100 + "";
pos = lat.indexOf(".");
llen = lat.length();
if (llen < 10) {
lat = lat.substring(0, pos) + "." + lat.substring(pos + 1, llen);
llen = lat.length();
for (int i = 0; i < (10 - llen); i++) {
lat = lat + "0";
}
}
else {
lat = lat.substring(0, pos) + "." + lat.substring(pos + 1, pos + 6);
}
}
else {
pos = lat.indexOf(".");
lat = lat.substring(0, pos) + lat.substring(pos + 1, pos + 3) + "." +
lat.substring(pos + 3, pos + 8);
}
/////////////////////
llen = lon.length();
if (llen < 11) {
lon = Double.parseDouble(lon) * 100 + "";
pos = lon.indexOf(".");
llen = lon.length();
if (llen < 11) {
lon = lon.substring(0, pos) + "." + lon.substring(pos + 1, llen);
llen = lon.length();
for (int i = 0; i < (11 - llen); i++) {
lon = lon + "0";
}
}
else {
lon = lon.substring(0, pos) + "." + lon.substring(pos + 1, pos + 6);
}
}
else {
pos = lon.indexOf(".");
lon = lon.substring(0, pos) + lon.substring(pos + 1, pos + 3) + "." +
lon.substring(pos + 3, pos + 8);
}
//////////////////
pos = alt.indexOf(".");
alt = alt.substring(0, pos);
int len = alt.length();
for (int i = 0; i < (5 - len); i++) {
alt = "0" + alt;
}
if (time.equals("")) {
time = "1899-12-29 4:00:00";
//1989-12-31 08:00:00
}
else if (time.equals("1989-12-31 08:00:00")) {
time = "1899-12-29 4:00:00";
}
txt = txt + "W " + wptName + " N" + lat + " E" + lon + " " + alt +" " + time + "\r\n";
}
public void appendWpt1(String wptName,String N,String E,String altitude,String time){
String lat = N+"";
String lon = E+"";
String alt = altitude + "";
int pos = lat.indexOf(".");
System.out.println(lat);
lat = lat.substring(0,pos)+lat.substring(pos+1,pos+3)+"."+lat.substring(pos+3,pos+8);
pos = lon.indexOf(".");
lon = lon.substring(0,pos)+lon.substring(pos+1,pos+3)+"."+lon.substring(pos+3,pos+8);
pos = alt.indexOf(".");
alt = alt.substring(0,pos);
int len = alt.length();
for(int i = 0;i<(5-len);i++){
alt = "0"+alt;
}
//W 0001 N3179.07693 E11730.11843 00020 26- 08-04 08:49\r\n
if (time.equals("")) {
txt = txt + "W " + wptName + " N" + lat + " E" + lon + " " + alt +
" 26- 08-04 08:49\r\n";
}
else {
txt = txt + "W " + wptName + " N" + lat + " E" + lon + " " + alt +
" " + time + "\r\n";
}
}
public void appendWpt(String wptName,double N,double E,double altitude,String time){
appendWpt(wptName,N+"",E+"",altitude+"",time);
}
public String getResult(){
return txt;
}
public static void main(String[] args) {
ElementToWpt elementtowpt = new ElementToWpt();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -