Help with php function

Caporegime
Joined
25 Jul 2005
Posts
28,851
Location
Canada
I have this php function I want to use but as my knowledge of php is restricted to changing small bits in wordpress templates I have no idea how to use it... :p

Basically I need to convert one set of coordinates from a (slightly) obscure coordinate system to lat/long (WGS84). What do I need to do with this function to allow me to do this (I assume input a text/excel file with x and y coords and output to another text/excel file with lat/long)?

PHP:
function rd2wgs ($x, $y) {     // Calculate WGS84 coördinates     $dX = ($x - 155000) * pow(10, - 5);     $dY = ($y - 463000) * pow(10, - 5);     $SomN = (3235.65389 * $dY) + (- 32.58297 * pow($dX, 2)) + (- 0.2475 *          pow($dY, 2)) + (- 0.84978 * pow($dX, 2) *          $dY) + (- 0.0655 * pow($dY, 3)) + (- 0.01709 *          pow($dX, 2) * pow($dY, 2)) + (- 0.00738 *          $dX) + (0.0053 * pow($dX, 4)) + (- 0.00039 *          $dX ^ 2 * pow($dY, 3)) + (0.00033 * pow(             $dX, 4) * $dY) + (- 0.00012 *          $dX * $dY);     $SomE = (5260.52916 * $dX) + (105.94684 * $dX * $dY) + (2.45656 *          $dX * pow($dY, 2)) + (- 0.81885 * pow(             $dX, 3)) + (0.05594 *          $dX * pow($dY, 3)) + (- 0.05607 * pow(             $dX, 3) * $dY) + (0.01199 *          $dY) + (- 0.00256 * pow($dX, 3) * pow(             $dY, 2)) + (0.00128 *          $dX * pow($dY, 4)) + (0.00022 * pow($dY,             2)) + (- 0.00022 * pow(             $dX, 2)) + (0.00026 *          pow($dX, 5));       $Latitude = 52.15517 + ($SomN / 3600);     $Longitude = 5.387206 + ($SomE / 3600);       return array(         'latitude' => $Latitude ,         'longitude' => $Longitude); }
http://www.god-object.com/2009/10/23/convert-rijksdriehoekscordinaten-to-latitudelongitude/

$x and $y are the locations I need to input the coordinates I assume but other than that I have no idea how it works. :o

To run it I assume I'd be able to upload it to my host, with the corresponding coordinate file, and then start it on there?

Thanks.:)

EDIT: No idea why it shows like that in the php section, it's displayed properly in the link.
 
I assume that is what the function I posted does? I just want to know how to use it/convert it into a useable script.:)

The file would just contain a list of coordinates, so for excel it would just be situated with column A having x coods in and column B with y coords. If a text file then it I guess it could just be X and Y coordinates on the same line with a space, with each set of coordinates on a seperate line, like...

124444 549994
139999 466323
124555 366225
 
Hmmm, thought it would be a lot more complex than I hoped...:(

The format would be what I posted above (or preferably that but in cells in excel), numbers are a minimum of 6 digits long but some have decimal places as well.

Think this is going to take a while, we've already spent a day or two on it and it's not even remotely relevant to the project in hand (need to put this data into a GIS program which is part of the actual project).

I'll have a look for the data input/output php then.:)
 
Back
Top Bottom