Here you can find the source of toDecimal(String coord)
Parameter | Description |
---|---|
coord | the String gps coordinate to be converted |
public static float toDecimal(String coord)
//package com.java2s; //License from project: Open Source License public class Main { /**// w ww . j a va2 s. co m * Converts degree minute second gps coordinate to decimal coordinate form * * @param coord * the String gps coordinate to be converted * @return the converted coordinate as a float */ public static float toDecimal(String coord) { // The indices for the two decimal points in the String coord int firstDec = coord.indexOf("."); int lastDec = coord.lastIndexOf("."); float deg = Float.parseFloat(coord.substring(0, firstDec)); float min = Float.parseFloat(coord.substring(firstDec + 1, lastDec)); float sec = Float.parseFloat(coord.substring(lastDec + 1, coord.length())); if (deg > 0) { return (deg + (min / 60 + sec / 3600)); } else { return (deg - (min / 60 + sec / 3600)); } } }