I have noticed a few posts by people seeking to display coords in DMS.
I thought I'd share my solution, using pmapper 4.0.
I added the following function to /plugins/coordinates/x_coords.php
Keep in mind all of my coords are in the western hemispheres. Hence my hard
code to make all x coords negative. You may need to modify this.
I also added a statement to apply the dd_to_dms function, in the same file,
code snippet below.
The name of the projection, in my case
'lat/lon WGS84 DMS'
Must exactly match one that you put in your XML config file, like this:
<coordinates>
<mapPrj name="UTM 17N" roundTo="0">
</mapPrj>
<prj name="lat/lon WGS84" roundTo="5">
<definition>init=epsg:4326</definition>
</prj>
<prj name="lat/lon WGS84 DMS" roundTo="4">
<definition>init=epsg:4326</definition>
</prj>
</coordinates>
function dd_to_dms($x="",$y="") {
if ($x == "") { $x = 0;}
if ($y == "") { $y = 0;}
$x = abs($x);
// $x *-1;
$dms[0][0] = floor($x);
$dms[0][1] = floor(($x-$dms[0][0])*60);
$dms[0][3] = (($x-$dms[0][0])*60 - $dms[0][1]) * 60;
$dms[0][2] = floor($dms[0][3]);
$dms[0][3] = floor(($dms[0][3] - $dms[0][2])*1000);
$dms[0][0] = $dms[0][0] *-1; //for western hemisphere
$dms[1][0] = floor($y);
$dms[1][1] = floor(($y-$dms[1][0])*60);
$dms[1][3] = (($y-$dms[1][0])*60 - $dms[1][1]) * 60;
$dms[1][2] = floor($dms[1][3]);
$dms[1][3] = floor(($dms[1][3] - $dms[1][2])*1000);
if (strlen($dms[0][0]) == 1) {$dms[0][0] = "0" . $dms[0][0];}
if (strlen($dms[0][1]) == 1) {$dms[0][1] = "0" . $dms[0][1];}
if (strlen($dms[0][2]) == 1) {$dms[0][2] = "0" . $dms[0][2];}
if (strlen($dms[0][3]) == 1) {$dms[0][3] = "00" . $dms[0][3];}
if (strlen($dms[0][3]) == 2) {$dms[0][3] = "0" . $dms[0][3];}
if (strlen($dms[1][0]) == 1) {$dms[1][0] = "0" . $dms[1][0];}
if (strlen($dms[1][1]) == 1) {$dms[1][1] = "0" . $dms[1][1];}
if (strlen($dms[1][2]) == 1) {$dms[1][2] = "0" . $dms[1][2];}
if (strlen($dms[1][3]) == 1) {$dms[1][3] = "00" . $dms[1][3];}
if (strlen($dms[1][3]) == 2) {$dms[1][3] = "0" . $dms[1][3];}
return $dms;
}
...............................
foreach ($prjList as $p) {
$prjName = _p($p['name']);
$roundTo = $p['roundTo'];
$toPrj = $p['definition'];
$prj = new Projection($clickX, $clickY, $fromPrj, $toPrj);
$x = $prj->getX();
$y = $prj->getY();
//round values
if ($prjName == 'lat/lon WGS84 DMS') //added by Ouvry March 2010
{
$dms = dd_to_dms($x,$y);
$y = $dms[1][0] . "'" . $dms[1][1] . "''" . $dms[1][2] . "." .
$dms[1][3];
$x = $dms[0][0] . "'" . $dms[0][1] . "''" . $dms[0][2] . "." .
$dms[0][3];
}
else
{
$x = round($x, $roundTo);
$y = round($y, $roundTo);
}
$prjJson .= "{\"prjName\": \"$prjName\", \"x\": \"$x\", \"y\":
\"$y\"},";
// $prjJson .= "{\"prjName\": \"$prjName\", \"x\": $x, \"y\": $y},";
}
...........................
-----Original Message-----
From: Armin Burger [mailto:[email protected]]
Sent: January 28, 2010 1:12 PM
To: [email protected]
Subject: Re: [pmapper-users] issue showing coordinates
On 28/01/2010 18:50, BYRON DELGADO wrote:
> Hi... i´m using p.mapper 4.x and i need to show in the coordinates
display in degrees, minutes and seconds because of the using of geographics
coordinates. I hope somebody can help me in this problem.
>
>
pm.zoombox.js, function 'displayCoordinates'
for customizations see this:
http://svn.pmapper.net/trac/wiki/FaqCustomizations#CustomizationsofCSSandJav
aScript
----------------------------------------------------------------------------
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the
business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
pmapper-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmapper-users
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
pmapper-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmapper-users