Here you can find the source of prettyPrintLatLon(double coord, boolean isCoordKindLat)
public static String prettyPrintLatLon(double coord, boolean isCoordKindLat)
//package com.java2s; /******************************************************************************* * Copyright (c) OSMCB developers/*from ww w. ja v a 2 s.c o m*/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ import java.text.DecimalFormat; public class Main { private static final DecimalFormat cDmsMinuteFormatter = new DecimalFormat("00"); private static final DecimalFormat cDmsSecondFormatter = new DecimalFormat("00.0"); public static String prettyPrintLatLon(double coord, boolean isCoordKindLat) { boolean neg = coord < 0.0; String c; if (isCoordKindLat) { c = (neg ? "S" : "N"); } else { c = (neg ? "W" : "E"); } double tAbsCoord = Math.abs(coord); int tDegree = (int) tAbsCoord; double tTmpMinutes = (tAbsCoord - tDegree) * 60; int tMinutes = (int) tTmpMinutes; double tSeconds = (tTmpMinutes - tMinutes) * 60; return c + tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'" + cDmsSecondFormatter.format(tSeconds) + "\""; } }