📄 waypointcommand.java
字号:
package net.aetherial.gis.garmin;
import java.io.*;
import java.util.*;
import net.aetherial.gis.garmin.*;
import net.aetherial.gis.surface.DialogProgress;
import net.aetherial.gis.surface.ItemValue;
import java.util.Vector;
public class WaypointCommand
{
public static Waypoint[] getWaypoints ()
{
Waypoint[] wps;
int type = GarminConfiguration.getWaypointType ();
if (type == 109)
{
wps = getWaypoints109 ();
}
else if (type == 108)
{
wps = getWaypoints108 ();
System.out.println("Waypoint 108 -- Class WaypointCommand.");
}
else
{
wps = getWaypoints103 ();
}
for(int i=0;i<wps.length;i++){
//wps[i].
}
return wps;
}
public static Waypoint108[] getWaypoints108 ()
{
DialogProgress fp = new DialogProgress();
fp.show();
LinkPacketConnection lpc;
Command cmd = new Command (Command.CMND_TRANSFER_WPT);
cmd.execute ();
lpc = cmd.getLinkPacketConnection ();
LinkPacket packet = lpc.receive ();
byte[] numBytes = packet.getPacketData ();
int numWaypoints = (((int) numBytes[1]) * 256) + (int) numBytes[0];
Waypoint108[] waypoints = new Waypoint108 [numWaypoints];
packet = lpc.receive ();
for (int i = 0; packet.getPacketType () != Garmin.XFER_COMPLETE; i++)
{
waypoints[i] = new Waypoint108 (packet.getPacketData(),fp);
packet = lpc.receive ();
waypoints[i].printDetails();
System.out.println("**** Recieve package in Class WaypointCommand");
}
lpc.destroy ();
fp.hide();
return waypoints;
}
public static Waypoint109[] getWaypoints109 ()
{
DialogProgress fp = new DialogProgress();
fp.show();
LinkPacketConnection lpc;
Command cmd = new Command (Command.CMND_TRANSFER_WPT);
cmd.execute ();
lpc = cmd.getLinkPacketConnection ();
LinkPacket packet = lpc.receive ();
byte[] numBytes = packet.getPacketData ();
int numWaypoints = (((int) numBytes[1]) * 256) + (int) numBytes[0];
if(numWaypoints<0){
numWaypoints = 0-numWaypoints;
}
//Waypoint109[] waypoints = new Waypoint109 [numWaypoints];
Vector v = new Vector();
Waypoint109 waypoints =null;
packet = lpc.receive ();
for (int i = 0; packet.getPacketType () != Garmin.XFER_COMPLETE; i++)
{
waypoints = new Waypoint109 (packet.getPacketData(),fp);
v.add(waypoints);
packet = lpc.receive ();
waypoints.printDetails();
}
/*
for (int i = 0; packet.getPacketType () != Garmin.XFER_COMPLETE; i++)
{
waypoints[i] = new Waypoint109 (packet.getPacketData(),fp);
packet = lpc.receive ();
waypoints[i].printDetails();
}
*/
lpc.destroy ();
fp.hide();
Waypoint109[] wayArray = new Waypoint109[v.size()];
for(int i =0;i<v.size();i++){
wayArray[i] = (Waypoint109)v.get(i);
}
//return waypoints;
return wayArray;
}
public static Waypoint103[] getWaypoints103 ()
{
LinkPacketConnection lpc;
Command cmd = new Command (Command.CMND_TRANSFER_WPT);
cmd.execute ();
lpc = cmd.getLinkPacketConnection ();
LinkPacket packet = lpc.receive ();
byte[] numBytes = packet.getPacketData ();
int numWaypoints = (((int) numBytes[1] * 256) + (int) numBytes[0]);
Waypoint103[] waypoints = new Waypoint103 [numWaypoints];
packet = lpc.receive ();
for (int i = 0; packet.getPacketType () != Garmin.XFER_COMPLETE; i++)
{
waypoints[i] = new Waypoint103 (packet.getPacketData());
packet = lpc.receive ();
}
lpc.destroy ();
return waypoints;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -