mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-03-30 04:31:04 +02:00
added audio support
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,10 @@
|
||||
package kst4contest.locatorUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Location class with methods allowing conversion to and from Maidenhead
|
||||
* locator (grid squares) based off of
|
||||
@@ -203,6 +208,28 @@ public class Location {
|
||||
return getDistanceKm(this, loc2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locator1 6 letter location string
|
||||
* @param locator2 6 letter location string
|
||||
* @return great circle distance in kilometers
|
||||
*/
|
||||
public double getDistanceKmByTwoLocatorStrings(String locator1,String locator2 ) {
|
||||
Location loc1 = new Location(locator1);
|
||||
Location loc2 = new Location(locator2);
|
||||
|
||||
Locale locale = new Locale("en", "UK");
|
||||
String pattern = "###.##";
|
||||
|
||||
DecimalFormat decimalFormat = (DecimalFormat)
|
||||
NumberFormat.getNumberInstance(locale);
|
||||
decimalFormat.applyPattern(pattern);
|
||||
|
||||
String format = decimalFormat.format(loc1.getDistanceKm(loc2));
|
||||
|
||||
// return df.format(number);
|
||||
return Double.parseDouble(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loc2
|
||||
* second location
|
||||
@@ -278,6 +305,19 @@ public class Location {
|
||||
return getBearing(this, loc2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bearing in degrees
|
||||
*/
|
||||
public double getBearingOfTwoLocatorStrings(String locator1, String locator2) {
|
||||
|
||||
Location loc1 = new Location(locator1);
|
||||
Location loc2 = new Location(locator2);
|
||||
|
||||
return getBearing(loc1, loc2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loc1
|
||||
* source location
|
||||
|
||||
38
src/test/java/kst4contest/test/TestLocatorUtils.java
Normal file
38
src/test/java/kst4contest/test/TestLocatorUtils.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package kst4contest.test;
|
||||
|
||||
import kst4contest.locatorUtils.Angle;
|
||||
import kst4contest.locatorUtils.Latitude;
|
||||
import kst4contest.locatorUtils.Location;
|
||||
import kst4contest.locatorUtils.Longitude;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class TestLocatorUtils {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Location location = new Location("JN49FL");
|
||||
Location location2 = new Location("JO51IJ");
|
||||
|
||||
// System.out.println(location.getDistanceKm(location2));
|
||||
// System.out.println(Location.getBearing(location, location2));
|
||||
|
||||
|
||||
System.out.println(new Location().getDistanceKmByTwoLocatorStrings("JN49FL", "Jo51ij") + "");
|
||||
|
||||
// String test = new Location().getDistanceKmByTwoLocatorStrings("JN49FL", "Jo51ij") + "";
|
||||
//
|
||||
// DecimalFormat df = new DecimalFormat("#.##");
|
||||
//
|
||||
// System.out.println(df.format(Double.parseDouble(test)));
|
||||
|
||||
// Angle angle = new Angle();
|
||||
// Latitude lat = new Latitude();
|
||||
// Longitude lon = new Longitude();
|
||||
//
|
||||
// location.setLatitude(lat);
|
||||
// location.setLongitude(lon);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user