📄 waypointcommand.java
字号:
package net.aetherial.gis.garmin;
import java.io.*;
import java.util.*;
import net.aetherial.gis.garmin.*;
public class WaypointCommand
{
public static Waypoint[] getWaypoints () { int type = GarminConfiguration.getWaypointType (); if (type == 109) { Waypoint109[] wps = getWaypoints109 (); return wps; } else if (type == 108) { Waypoint108[] wps = getWaypoints108 (); return wps; } else { Waypoint103[] wps = getWaypoints103 (); return wps; } } public static Waypoint108[] getWaypoints108 ()
{
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());
packet = lpc.receive ();
}
lpc.destroy ();
return waypoints;
}
public static Waypoint109[] getWaypoints109 () { 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]; Waypoint109[] waypoints = new Waypoint109 [numWaypoints]; packet = lpc.receive (); for (int i = 0; packet.getPacketType () != Garmin.XFER_COMPLETE; i++) { waypoints[i] = new Waypoint109 (packet.getPacketData()); packet = lpc.receive (); } lpc.destroy (); return waypoints; }
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 + -