Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何处理像50°;32';20.548\\\”;N";?_Java_Android_Maps - Fatal编程技术网

Java 如何处理像50°;32';20.548\\\”;N";?

Java 如何处理像50°;32';20.548\\\”;N";?,java,android,maps,Java,Android,Maps,我想在我的Android项目中实现一个映射。我已经准备好了地图、coords和所有方法,但我发现我不知道如何处理我收到的coords格式: 50°32'20.548\\'N“ Android Studio希望采用如下两种格式:-33.852151.211 ……我不知道如何转换它。有没有人处理过类似的问题,能帮我一下 谢谢:) 我必须与之合作的合作伙伴(无法更改): 一度是60分钟,一分钟是60秒 e、 g 50°30'与50.5相同您应该编写一个函数,该函数接收字符串并将这些坐标转换为数字,然后

我想在我的Android项目中实现一个映射。我已经准备好了地图、coords和所有方法,但我发现我不知道如何处理我收到的coords格式:

50°32'20.548\\'N“

Android Studio希望采用如下两种格式:-33.852151.211 ……我不知道如何转换它。有没有人处理过类似的问题,能帮我一下

谢谢:)

我必须与之合作的合作伙伴(无法更改):


一度是60分钟,一分钟是60秒

e、 g


50°30'与50.5相同

您应该编写一个函数,该函数接收字符串并将这些坐标转换为数字,然后您可以使用这些数字。

该类有一个静态方法来执行DMS字符串转换(到双精度)-但首先需要调整字符串以匹配可接受的“DD:MM:SS.SSSS”格式。转换后,需要针对半球调整标志:

public class HelloWorld
{
    public static void main(String[] args)
    {
       // The triple backslash is data author's attempt to escape the double-quote.
       String s = "50°32'20.548\\\"N";

       // Get rid of any residual backslashes
       s = s.replace("\\","");

       // split string into constituent parts using apparent separators
       String[] dms = s.split("[°'\"]");

       // form 'newS' which complies with Location.FORMAT_SECONDS
       String newS = dms[0]+":"+dms[1]+":"+dms[2];

       // and grab hemisphere (to implement sign)
       String hemi = dms[3];

       double coord = Location.convert(newS);
       if (hemi.compareTo("W") == 0 || hemi.compareTo("S") == 0) {
           coord = -coord;
       }
   }
}

public class HelloWorld
{
    public static void main(String[] args)
    {
       // The triple backslash is data author's attempt to escape the double-quote.
       String s = "50°32'20.548\\\"N";

       // Get rid of any residual backslashes
       s = s.replace("\\","");

       // split string into constituent parts using apparent separators
       String[] dms = s.split("[°'\"]");

       // form 'newS' which complies with Location.FORMAT_SECONDS
       String newS = dms[0]+":"+dms[1]+":"+dms[2];

       // and grab hemisphere (to implement sign)
       String hemi = dms[3];

       double coord = Location.convert(newS);
       if (hemi.compareTo("W") == 0 || hemi.compareTo("S") == 0) {
           coord = -coord;
       }
   }