开发者

Is it possible to give a sexagesimal input for Latitude and Longitude

i am trying to figure out if you can give a sexagesimal input as a location , just like you can give a decimal input in android like this:

 // Decimal input
 double src_lat = 46.550952;
 double src_long = 15.651366;

 GeoPoint srcGeoPoint = new GeoPoint((int) (src_lat * 1E6),
        (int) (src_long * 1E6));

so my question is as follows - is there a way to enter sexagesimal numbers and not decimal? I have sexagesimal numbers in my database, in the form of "46.550952, 15.651366, etc." but when i enter them as decimals it obviously gives me the wrong location on Google Maps , which is a problem.

I would be really gratefull for any answers or findings.

--- EDIT ---

I just gave up and made a function that turns sexagesimal into decimal =) Since all of the strings (numbe开发者_StackOverflowrs) i get are 10 chars long i can simply substring the minutes and seconds.

the code is below:

private double turnSexagesimalToDecimal(String number) {
    double sumDivMinutes = 0;
        String degree = number;

        String degrees = degree.substring(0, 2);

        String minutes = degree.substring(3, 5);

        String second1 = degree.substring(5, 7);
        String second2 = degree.substring(7);
        String seconds = second1 + "." + second2;

        double divideSeconds = Double.parseDouble(seconds) / 60;

        sumDivMinutes = (Double.parseDouble(minutes) + divideSeconds) / 60;

        sumDivMinutes = (double)Math.round(sumDivMinutes * 1000000) / 1000000;
        sumDivMinutes = sumDivMinutes + Double.parseDouble(degrees);

    return sumDivMinutes;
}


why not just write a function to convert between the two?

double decimalToSexagecimal(double decimalDegrees) { 
    String dd = new String(decimalDegrees);
    String[] ddArr = dd.split(".");
    // .75/100 = 75, .75 * 60/100
    double sd = Double.valueOf(ddArr).doubleValue() * 60 / 100;
    return Double.valueOf(ddArr[0] + "." + sd);
}

sexagecimalToDecimal(double sexagecimalDegreees) { ... }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜