How to use Java to realize the minute-second conversion between longitude and latitude and degree in Android Geographic Information system
This article introduces the relevant knowledge of "how to use Java to realize the longitude, latitude and degree conversion of Android GIS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
/ * * convert latitude and longitude into degree minute and second format * @ param du 116.418847 * @ return 116o 2507.85 "* / public static String changeToDFM (double du) {int du1 = (int) du; double tp = (du-du1) * 60; int fen = (int) tp String miao = String.format ("% .2f", Math.abs (tp-fen) * 60); return du1 + "°" + Math.abs (fen) + "'" + miao + "\" } / * degrees turn to latitude and longitude * @ param dms 116 °25 °7.85 "* @ return 116.418847 * / public static double changeToDu (String dms) {if (dms = = null) return 0; try {dms = dms.replace (","); String [] str2 = dms.split ("°") If (str2.length < 2) return 0; int d = Integer.parseInt (str2 [0]); String [] str3 = str2 [1] .split ("\"); if (str3.length < 2) return 0; int f = Integer.parseInt (str3 [0]); String str4 = str3 [1] .substring (0, str3 [1] .length ()-1) Double m = Double.parseDouble (str4); double fen = f + (m / 60); double du = (fen / 60) + Math.abs (d); if (d < 0) du =-du; return du;} catch (Exception e) {e.printStackTrace ();} return 0 } "how to use Java to achieve Android geographic information system longitude and latitude and degree minute-second conversion" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!