Commit f45f9a84 authored by Eric Duminil's avatar Eric Duminil
Browse files

Unused utils

parent b2bc8047
......@@ -3,8 +3,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -28,27 +26,6 @@ private RegionChooserUtils() {
// only static use
}
/**
* Writes down the input coordinates in a string, without "." or "-". E.g. "N48_77__E9_18" for (48.77, 9.18) and
* "S12_345__W6_789" for (-12.345, -6.789).
*
* Useful for caching geolocated information. The process should be reversible.
*
* WARNING: LATITUDE FIRST!
*
* @param latitude
* @param longitude
* @return Filename friendly string for given coordinates
*/
public static String coordinatesForFilename(double latitude, double longitude) {
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
symbols.setDecimalSeparator('.');
DecimalFormat df = new DecimalFormat("+#.######;-#.######", symbols);
String lat = df.format(latitude).replace('-', 'S').replace('+', 'N');
String lon = df.format(longitude).replace('-', 'W').replace('+', 'E');
return (lat + "__" + lon).replace('.', '_');
}
/**
* The srsName (The name by which this reference system is identified) inside the CityGML file can have multiple
* formats. This method tries to parse the string and detect the corresponding reference system. If it is found, it
......@@ -149,27 +126,6 @@ public static CoordinateReferenceSystem crsFromCityGMLHeader(Path citygmlPath) t
}
}
/**
* The haversine formula determines the great-circle distance between two points on a sphere given their longitudes
* and latitudes. https://en.wikipedia.org/wiki/Haversine_formula
*
* @param latitude1
* @param longitude1
* @param latitude2
* @param longitude2
* @return distance in kilometer
*/
public static Double greatCircleDistance(Double latitude1, Double longitude1, Double latitude2, Double longitude2) {
final int earthRadius = 6371; // [km]. Radius of the earth
double latDistance = Math.toRadians(latitude2 - latitude1);
double lonDistance = Math.toRadians(longitude2 - longitude1);
double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) + Math.cos(Math.toRadians(latitude1))
* Math.cos(Math.toRadians(latitude2)) * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return earthRadius * c;
}
/**
* Finds every CityGML in every .proj folder in a repository.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment