use of com.jwetherell.openmap.common.ZonedUTMPoint in project Osmand by osmandapp.
the class OsmAndFormatter method getFormattedCoordinates.
public static String getFormattedCoordinates(double lat, double lon, int outputFormat) {
StringBuilder result = new StringBuilder();
if (outputFormat == FORMAT_DEGREES_SHORT) {
result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat));
} else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) {
boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR;
String rtlCoordinates = isLeftToRight ? "" : "\u200f";
String rtlCoordinatesPunctuation = isLeftToRight ? ", " : " ,";
result.append(rtlCoordinates).append(formatCoordinate(lat, outputFormat)).append(rtlCoordinates).append(" ").append(rtlCoordinates).append(lat > 0 ? NORTH : SOUTH).append(rtlCoordinates).append(rtlCoordinatesPunctuation).append(rtlCoordinates).append(formatCoordinate(lon, outputFormat)).append(rtlCoordinates).append(" ").append(rtlCoordinates).append(lon > 0 ? EAST : WEST);
} else if (outputFormat == UTM_FORMAT) {
ZonedUTMPoint pnt = new ZonedUTMPoint(new LatLonPoint(lat, lon));
result.append(pnt.zone_number).append(pnt.zone_letter).append(" ").append((long) pnt.easting).append(" ").append((long) pnt.northing);
} else if (outputFormat == OLC_FORMAT) {
String r;
try {
r = getLocationOlcName(lat, lon);
} catch (RuntimeException e) {
r = "0, 0";
}
result.append(r);
} else if (outputFormat == MGRS_FORMAT) {
MGRSPoint pnt = new MGRSPoint(new LatLonPoint(lat, lon));
try {
result.append(pnt.toFlavoredString(5));
} catch (java.lang.Error e) {
e.printStackTrace();
}
} else if (outputFormat == SWISS_GRID_FORMAT) {
double[] swissGrid = SwissGridApproximation.convertWGS84ToLV03(new LatLon(lat, lon));
DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(Locale.US);
formatSymbols.setDecimalSeparator('.');
formatSymbols.setGroupingSeparator(' ');
DecimalFormat swissGridFormat = new DecimalFormat("###,###.##", formatSymbols);
result.append(swissGridFormat.format(swissGrid[0]) + ", " + swissGridFormat.format(swissGrid[1]));
} else if (outputFormat == SWISS_GRID_PLUS_FORMAT) {
double[] swissGrid = SwissGridApproximation.convertWGS84ToLV95(new LatLon(lat, lon));
DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(Locale.US);
formatSymbols.setDecimalSeparator('.');
formatSymbols.setGroupingSeparator(' ');
DecimalFormat swissGridFormat = new DecimalFormat("###,###.##", formatSymbols);
result.append(swissGridFormat.format(swissGrid[0]) + ", " + swissGridFormat.format(swissGrid[1]));
}
return result.toString();
}
use of com.jwetherell.openmap.common.ZonedUTMPoint in project Osmand by osmandapp.
the class QuickSearchCoordinatesFragment method parseZonedUtmPoint.
private LatLon parseZonedUtmPoint(double northing, double easting, int zoneNumber, char zoneLetter) {
try {
ZonedUTMPoint point = new ZonedUTMPoint(northing, easting, zoneNumber, zoneLetter);
LatLonPoint latLonPoint = point.ZonedUTMtoLL();
return new LatLon(latLonPoint.getLatitude(), latLonPoint.getLongitude());
} catch (NumberFormatException e) {
}
return null;
}
Aggregations