本文整理了Java中slash.common.io.Transfer.formatDoubleAsString()
方法的一些代码示例,展示了Transfer.formatDoubleAsString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transfer.formatDoubleAsString()
方法的具体详情如下:
包路径:slash.common.io.Transfer
类名称:Transfer
方法名:formatDoubleAsString
暂无
代码示例来源:origin: cpesch/RouteConverter
private String formatPosition(Double aDouble) {
return formatDoubleAsString(aDouble, 8).replace('.', ',');
}
代码示例来源:origin: cpesch/RouteConverter
public static String formatDoubleAsString(Double aDouble, int exactFractionCount) {
StringBuilder buffer = new StringBuilder(formatDoubleAsString(aDouble));
int index = buffer.indexOf(".");
if (index == -1) {
buffer.append(".");
}
while (buffer.length() - index <= exactFractionCount)
buffer.append("0");
while (buffer.length() - index > exactFractionCount + 1)
buffer.deleteCharAt(buffer.length() - 1);
return buffer.toString();
}
代码示例来源:origin: cpesch/RouteConverter
private void setValueAsDouble(ColumnType type, Double value) {
setValueAsString(type, formatDoubleAsString(value));
}
代码示例来源:origin: cpesch/RouteConverter
public void write(MagicMapsPthRoute route, PrintWriter writer, int startIndex, int endIndex) {
List<GkPosition> positions = route.getPositions();
writer.println("# Path2D file format V1.0 - MagicMaps");
writer.println("Pathsize: " + positions.size());
writer.println("selectedPoint: 1");
for (int i = startIndex; i < endIndex; i++) {
GkPosition position = positions.get(i);
String right = formatDoubleAsString(position.getRight(), 2);
String height = formatDoubleAsString(position.getHeight(), 2);
writer.println(right + " \t " + height);
}
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 7);
String latitude = formatDoubleAsString(position.getLatitude(), 7);
String elevation = position.getElevation() != null ? formatDoubleAsString(position.getElevation(), 1) : "0.0";
writer.println(latitude + SEPARATOR + longitude + SEPARATOR + elevation);
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 6);
String latitude = formatDoubleAsString(position.getLatitude(), 6);
String description = escape(position.getDescription());
String phone = null;
int plus = description.lastIndexOf('+');
if (plus != -1) {
phone = description.substring(plus);
description = description.substring(0, plus - 1);
}
writer.println(longitude + TAB + latitude + TAB + description + (phone != null ? TAB + phone : ""));
}
代码示例来源:origin: cpesch/RouteConverter
String createURL(List<Wgs84Position> positions, int startIndex, int endIndex) {
StringBuilder buffer = new StringBuilder();
buffer.append("navigon");
String mapName = trim(preferences.get("navigonUrlMapName", null));
if (mapName != null)
buffer.append(mapName);
buffer.append("://route/?");
for (int i = startIndex; i < endIndex; i++) {
Wgs84Position position = positions.get(i);
String longitude = formatDoubleAsString(position.getLongitude(), 6);
String latitude = formatDoubleAsString(position.getLatitude(), 6);
if (i > startIndex)
buffer.append("&");
buffer.append("target=coordinate//").append(longitude).append("/").append(latitude);
}
return buffer.toString();
}
代码示例来源:origin: cpesch/RouteConverter
String createURL(List<Wgs84Position> positions, int startIndex, int endIndex) {
StringBuilder buffer = new StringBuilder("http://www.motoplaner.de/#");
for (int i = startIndex; i < endIndex; i++) {
Wgs84Position position = positions.get(i);
String longitude = position.getLongitude() != null ? formatDoubleAsString(position.getLongitude(), 6) : null;
String latitude = position.getLatitude() != null ? formatDoubleAsString(position.getLatitude(), 6) : null;
if (longitude != null && latitude != null)
buffer.append(latitude).append(",").append(longitude).append(";1");
if (i < endIndex - 1)
buffer.append(",");
}
return buffer.toString();
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String latitude = formatDoubleAsString(position.getLatitude(), 5);
String longitude = formatDoubleAsString(position.getLongitude(), 5);
String description = formatDescription(position.getDescription());
writer.println(STREET + NAME_VALUE_SEPARATOR + QUOTE + description + QUOTE + " " +
PT + NAME_VALUE_SEPARATOR + QUOTE + longitude + " " + latitude + QUOTE);
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 7);
String latitude = formatDoubleAsString(position.getLatitude(), 7);
String description = escape(position.getDescription(), SEPARATOR, ';');
writer.println(longitude + SEPARATOR + latitude + SEPARATOR + "\"" + description + "\"");
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 6);
String latitude = formatDoubleAsString(position.getLatitude(), 6);
String description = escape(position.getDescription());
writer.println(longitude + SEPARATOR + latitude + SEPARATOR + "\"" + description + "\"");
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String latitude = formatDoubleAsString(position.getLatitude(), 7);
String longitude = formatDoubleAsString(position.getLongitude(), 7);
String elevation = formatDoubleAsString(position.getElevation(), 7);
String dateAndTime = position.hasTime() ? createDateFormat(DATE_AND_TIME_FORMAT).format(position.getTime().getTime()) : "00.00.00 00:00:=00";
writer.println(latitude + SEPARATOR + longitude + SEPARATOR + elevation + SEPARATOR + dateAndTime);
}
}
代码示例来源:origin: cpesch/RouteConverter
private static String formatDoubleAsString(Double aDouble, int maximumFractionCount) {
if (aDouble != null && isReduceDecimalPlaceToReasonablePrecision())
aDouble = roundFraction(aDouble, maximumFractionCount);
return Transfer.formatDoubleAsString(aDouble);
}
代码示例来源:origin: cpesch/RouteConverter
String createURL(List<Wgs84Position> positions, int startIndex, int endIndex) {
StringBuilder buffer = new StringBuilder("http://maps.google.com/maps?ie=UTF8&");
for (int i = startIndex; i < endIndex; i++) {
Wgs84Position position = positions.get(i);
String longitude = position.getLongitude() != null ? formatDoubleAsString(position.getLongitude(), 6) : null;
String latitude = position.getLatitude() != null ? formatDoubleAsString(position.getLatitude(), 6) : null;
String comment = encodeDescription(trim(position.getDescription()));
if (i == startIndex) {
buffer.append("saddr=").append(comment);
if(longitude != null && latitude != null)
buffer.append("%40").append(latitude).append(",").append(longitude);
if (endIndex > startIndex + 1)
buffer.append("&daddr=");
} else {
if (i > startIndex + 1 && i < endIndex)
buffer.append("+").append(DESTINATION_SEPARATOR);
buffer.append(comment);
if(longitude != null && latitude != null)
buffer.append("%40").append(latitude).append(",").append(longitude);
}
}
return buffer.toString();
}
代码示例来源:origin: cpesch/RouteConverter
private Route createRoute(NavigonCruiserRoute route) {
Route result = new Route();
result.creator = GENERATED_BY;
result.name = route.getName();
for (Wgs84Position position : route.getPositions()) {
result.coords.add(formatDoubleAsString(position.getLatitude(), 5) + "," +
formatDoubleAsString(position.getLongitude(), 5));
}
return result;
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 7);
String latitude = formatDoubleAsString(position.getLatitude(), 7);
String description = escape(position.getDescription(), SEPARATOR, ';');
description = escape(description, '\"', ';');
writer.println(latitude + SEPARATOR + longitude + SEPARATOR + description);
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String longitude = formatDoubleAsString(position.getLongitude(), 6);
String latitude = formatDoubleAsString(position.getLatitude(), 6);
String[] strings = position.getDescription().split(";");
String description = strings.length > 0 ? escape(strings[0], 60) : "";
String extra = strings.length > 1 ? escape(strings[1], 60) : "";
String phone = strings.length > 2 ? escape(strings[2], 30) : "";
writer.println(longitude + SEPARATOR + " " + latitude + SEPARATOR + " " +
QUOTE + description + QUOTE + SEPARATOR + " " +
QUOTE + extra + QUOTE + SEPARATOR + " " +
QUOTE + phone + QUOTE);
}
}
代码示例来源:origin: cpesch/RouteConverter
@Test
public void testFormatDoubleAsString() {
assertEquals("0.001", formatDoubleAsString(0.001));
assertEquals("0.0001", formatDoubleAsString(0.0001));
assertEquals("0.00001", formatDoubleAsString(0.00001));
assertEquals("0.000001", formatDoubleAsString(0.000001));
assertEquals("0.0000001", formatDoubleAsString(0.0000001));
assertEquals("1.00000", formatDoubleAsString(1.0, 5));
assertEquals("1.50000", formatDoubleAsString(1.5, 5));
assertEquals("1.05000", formatDoubleAsString(1.05, 5));
assertEquals("1.00500", formatDoubleAsString(1.005, 5));
assertEquals("1.00005", formatDoubleAsString(1.00005, 5));
assertEquals("1.00000", formatDoubleAsString(1.000005, 5));
assertEquals("1.00000", formatDoubleAsString(1.0000005, 5));
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String latitude = formatDoubleAsString(position.getLatitude(), 6);
String longitude = formatDoubleAsString(position.getLongitude(), 6);
String elevation = position.getElevation() != null ? formatElevationAsString(position.getElevation()) : "0.0";
String time = formatTime(position.getTime());
// try to parse number from description to make read/write round trip easier
int number;
try {
number = parseInt(position.getDescription());
}
catch (NumberFormatException e) {
number = index + 1;
}
writer.println(fillWithSpaces(Integer.toString(number), 5) +
fillWithSpaces(latitude, 12) +
fillWithSpaces(longitude, 13) +
fillWithSpaces(elevation, 11) +
fillWithSpaces("0.0", 13) +
" " + time);
}
}
代码示例来源:origin: cpesch/RouteConverter
protected void writePosition(Wgs84Position position, PrintWriter writer, int index, boolean firstPosition) {
String date = formatDate(position.getTime());
String time = formatTime(position.getTime());
String latitude = formatDoubleAsString(Math.abs(position.getLatitude()), 6);
String northOrSouth = position.getLatitude() != null && position.getLatitude() < 0.0 ? "S" : "N";
String longitude = formatDoubleAsString(Math.abs(position.getLongitude()), 6);
String westOrEast = position.getLongitude() != null && position.getLongitude() < 0.0 ? "W" : "E";
String height = position.getElevation() != null ? formatElevationAsString(position.getElevation()) : "0.0";
String speed = position.getSpeed() != null ? formatSpeedAsString(position.getSpeed()) : "0.0";
String heading = position.getHeading() != null ? formatHeadingAsString(position.getHeading()) : "0.0";
if (firstPosition)
previousPosition = null;
String distance = previousPosition != null ? formatElevationAsString(position.calculateDistance(previousPosition)) : "0.0";
previousPosition = position;
writer.println(Integer.toString(index + 1) + SEPARATOR + "T" + SEPARATOR +
date + SEPARATOR + time + SEPARATOR + "SPS" + SEPARATOR +
latitude + SEPARATOR + northOrSouth + SEPARATOR +
longitude + SEPARATOR + westOrEast + SEPARATOR +
height + " M" + SEPARATOR +
speed + " km/h" + SEPARATOR +
heading + SEPARATOR +
distance + " M" + SEPARATOR);
}
}
内容来源于网络,如有侵权,请联系作者删除!