OT: decimal degree conversion

Matt Brown mbrown at AL1CALL.COM
Thu Jan 13 06:44:07 PST 2005


Joel,

instead of concatenating as strings, you would probably be better off to add

ie,

$longdiv1 = $arrCoords[1] / 60;
$longdiv2 = $arrCoords[2] / 3600;

// create our plotting location

$plot = $long + $longdiv1 + $longdiv2;

Matt

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
Behalf Of MapServer User
Sent: Thursday, January 13, 2005 7:47 AM
To: MAPSERVER-USERS at lists.umn.edu
Subject: [UMN_MAPSERVER-USERS] OT: decimal degree conversion


MapServer Users:

I could use some quick help in diagnosing the problem I have with
plotting issues.  I use the following PHP to convert a lat/long
(xx:xx:xx) to decimal degrees.

If anyone could point out the flaws, I would appreciate it.  Some
plot fine.  Others appear to be off.  I'm assuming this is the culprit.

Thanks.

// our plotting function to specify degrees
    function plot_degrees($location) {
        // create an array of our data
        $arrCoords = explode(":", $location);

        // set our data
        $long = $arrCoords[0];
        $longdiv1 = round((($arrCoords[1] / 60) * 100));
        $longdiv2 = round((($arrCoords[2] / 3600) * 100000));

        // create our plotting location
        $plot = $long .= "." . $longdiv1 . $longdiv2;

        // return our appended string
        return $plot;
    }


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
Behalf Of MapServer User
Sent: Thursday, January 13, 2005 7:47 AM
To: MAPSERVER-USERS at lists.umn.edu
Subject: [UMN_MAPSERVER-USERS] OT: decimal degree conversion


MapServer Users:

I could use some quick help in diagnosing the problem I have with
plotting issues.  I use the following PHP to convert a lat/long
(xx:xx:xx) to decimal degrees.

If anyone could point out the flaws, I would appreciate it.  Some
plot fine.  Others appear to be off.  I'm assuming this is the culprit.

Thanks.

// our plotting function to specify degrees
    function plot_degrees($location) {
        // create an array of our data
        $arrCoords = explode(":", $location);

        // set our data
        $long = $arrCoords[0];
        $longdiv1 = round((($arrCoords[1] / 60) * 100));
        $longdiv2 = round((($arrCoords[2] / 3600) * 100000));

        // create our plotting location
        $plot = $long .= "." . $longdiv1 . $longdiv2;

        // return our appended string
        return $plot;
    }

Joel



More information about the MapServer-users mailing list