* @param strName the name
* @param desX the destination x
* @param desY the destination y
*/
public void moveToDestination( String strName, Double desX, Double desY ){
Unit ship = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strName);
Unit location = ship.get("Location");
Double X = ship.get("X").getDataByDouble();
Double Y = ship.get("Y").getDataByDouble();
//random velocity
// 1 knot : 1.8532 km : 6.85684 dot
// 0.539607166 knot : 1 km : 3.7 dot
// 10 knot : 18.532 km : 68.5684 dot : 60 min
// 1 dot : 0.875038648 min
// 1.142806667 dot : 1 min
//
//1 knot = 1 nautical mile per hour = 6076 feet per hour
//1 mph =1 mile per hour = 5280 feet per hour
Double randomKnot = 10 + ((Math.random()*1)*((Math.random() < .5d)?-1:1));
// TODO change this portion if the speed is important for estimating ship type or identifying terrorists
// change the speed by type of ship
// Unit type = ship.get("Type");
// if(type.getData().equalsIgnoreCase("BombingFishingShip")
// || type.getData().equalsIgnoreCase("BombingMerchantShip")
// || type.getData().equalsIgnoreCase("IllicitCargoMerchantShip")
// || type.getData().equalsIgnoreCase("IllicitCargoFishingShip")) {
// //
// randomKnot = 15 + ((Math.random()*5)*((Math.random() < .5d)?-1:1));
// }
Double dotSpeed = getDotByKnot(randomKnot);
//get new position based on move size
double[] newPos = getNewPosition(dotSpeed, X, Y, desX, desY);
//new position
double xNew = X + newPos[0];
double yNew = Y + newPos[1];
//3. Put new position of this ship
ship.get("X").setData(xNew);
ship.get("Y").setData(yNew);
ship.get("Longitude").setData(getLongitudeByX(xNew));
ship.get("Latitude").setData(getLatitudeByY(yNew));
ship.get("Speed").setData(randomKnot);
//find current location
// location.setData("A");
location.setData(getCurrentLocation( ship ));
//System.out.println(strName + ": x: " + xNew +"y: " + yNew);
}