Spodaj je php skripta, za preracun iz geografskih koordinat LAM FI v WGS84 ravninske koordinate.
pregledovalnik
PRETVORBA iz geografskih koordinat LAM FI v WGS84:
Ge. dolžina=
14.588609055128
Ge. širina =
46.056494347488
Priredil: ZORKO VIČAR, nov. 2004
  Original C version Copyright © 2001 by Jef Poskanzer
. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Almost entirely based on code by Jef Poskanzer
and he should get all of the credit. This is simply a straight port of Jef's decimal to UTM conversion routine originally written in C. You need this to build your own frontend for TerraServer. Hopefully it will save other PHP folks some time! **/ // WGS84 datum constants define("ECCENTRICITY_SQUARED", 0.00669437999013); // square of eccentricity of equatorial cross-section define("ECC_PRIME_SQUARED", ECCENTRICITY_SQUARED / ( 1.0 - ECCENTRICITY_SQUARED )); // eccentricity prime squared define("EQUATORIAL_RADIUS", 6378137.0); // radius of Earth in meters define ("K0", 0.9996); // scale factor /** * convert decimal geographic coordinates to UTM * * @param $latitude latitude as decimal * @param $longitude longitude as decimal * @return $return array of coordinates as UTM * $return["northing"] UTM northing * $return["easting"] UTM easting * $return["zone"] UTM zone * $return["utmLetter"] correct UTM letter designator for the given latitude * */ function convertDecimalToUTM($latitude,$longitude) { if (!is_numeric($latitude) || !is_numeric($longitude)) return; $latitude = floatval($latitude); $longitude = floatval($longitude); // make sure longitude is between -180 and 180 if ($longitude < -180.0) $longitude += 360.0; if ($longitude > 180.0) $longitude -= 360.0; // get UTM letter if ( $latitude <= 84.0 && $latitude >= 72.0 ) $utmLetter = 'X'; else if ( $latitude < 72.0 && $latitude >= 64.0 ) $utmLetter = 'W'; else if ( $latitude < 64.0 && $latitude >= 56.0 ) $utmLetter = 'V'; else if ( $latitude < 56.0 && $latitude >= 48.0 ) $utmLetter = 'U'; else if ( $latitude < 48.0 && $latitude >= 40.0 ) $utmLetter = 'T'; else if ( $latitude < 40.0 && $latitude >= 32.0 ) $utmLetter = 'S'; else if ( $latitude < 32.0 && $latitude >= 24.0 ) $utmLetter = 'R'; else if ( $latitude < 24.0 && $latitude >= 16.0 ) $utmLetter = 'Q'; else if ( $latitude < 16.0 && $latitude >= 8.0 ) $utmLetter = 'P'; else if ( $latitude < 8.0 && $latitude >= 0.0 ) $utmLetter = 'N'; else if ( $latitude < 0.0 && $latitude >= -8.0 ) $utmLetter = 'M'; else if ( $latitude < -8.0 && $latitude >= -16.0 ) $utmLetter = 'L'; else if ( $latitude < -16.0 && $latitude >= -24.0 ) $utmLetter = 'K'; else if ( $latitude < -24.0 && $latitude >= -32.0 ) $utmLetter = 'J'; else if ( $latitude < -32.0 && $latitude >= -40.0 ) $utmLetter = 'H'; else if ( $latitude < -40.0 && $latitude >= -48.0 ) $utmLetter = 'G'; else if ( $latitude < -48.0 && $latitude >= -56.0 ) $utmLetter = 'F'; else if ( $latitude < -56.0 && $latitude >= -64.0 ) $utmLetter = 'E'; else if ( $latitude < -64.0 && $latitude >= -72.0 ) $utmLetter = 'D'; else if ( $latitude < -72.0 && $latitude >= -80.0 ) $utmLetter = 'C'; else $utmLetter = 'Z'; // returns 'Z' if the latitude is outside the UTM limits of 84N to 80S $lat_rad = $latitude * M_PI / 180.0; $long_rad = $longitude * M_PI / 180.0; $zone = (int) ( ( $longitude + 180 ) / 6 ) + 1; if ( $latitude >= 56.0 && $latitude < 64.0 && $longitude >= 3.0 && $longitude < 12.0 ) $zone = 32; // Special zones for Svalbard. if ($latitude >= 72.0 && $latitude < 84.0 ) { if ( $longitude >= 0.0 && $longitude < 9.0 ) $zone = 31; else if ( $longitude >= 9.0 && $longitude < 21.0 ) $zone = 33; else if ( $longitude >= 21.0 && $longitude < 33.0 ) $zone = 35; else if ( $longitude >= 33.0 && $longitude < 42.0 ) $zone = 37; } $long_origin = ( $zone - 1 ) * 6 - 180 + 3; // +3 puts origin in middle of zone $long_origin_rad = $long_origin * M_PI / 180.0; $N = EQUATORIAL_RADIUS / sqrt( 1.0 - ECCENTRICITY_SQUARED * sin( $lat_rad ) * sin( $lat_rad ) ); $T = tan( $lat_rad ) * tan( $lat_rad ); $C = ECC_PRIME_SQUARED * cos( $lat_rad ) * cos( $lat_rad ); $A = cos( $lat_rad ) * ( $long_rad - $long_origin_rad ); $M = EQUATORIAL_RADIUS * ( ( 1.0 - ECCENTRICITY_SQUARED / 4 - 3 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 64 - 5 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 256 ) * $lat_rad - ( 3 * ECCENTRICITY_SQUARED / 8 + 3 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 32 + 45 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 1024 ) * sin( 2 * $lat_rad ) + ( 15 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 256 + 45 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 1024 ) * sin( 4 * $lat_rad ) - ( 35 * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED * ECCENTRICITY_SQUARED / 3072 ) * sin( 6 * $lat_rad ) ); $easting = K0 * $N * ( $A + ( 1 - $T + $C ) * $A * $A * $A / 6 + ( 5 - 18 * $T + $T * $T + 72 * $C - 58 * ECC_PRIME_SQUARED ) * $A * $A * $A * $A * $A / 120 ) + 500000.0; $northing = K0 * ( $M + $N * tan( $lat_rad ) * ( $A * $A / 2 + ( 5 - $T + 9 * $C + 4 * $C * $C ) * $A * $A * $A * $A / 24 + ( 61 - 58 * $T + $T * $T + 600 * $C - 330 * ECC_PRIME_SQUARED ) * $A * $A * $A * $A * $A * $A / 720 ) ); if ( $latitude < 0.0 ) $northing += 10000000.0; // 1e7 meter offset for southern hemisphere $return["northing"] = $northing; $return["easting"] = $easting; $return["zone"] = $zone; $return["utmLetter"] = $utmLetter; return $return; } //vzeto iz: http://www.jimstudnicki.com/code/decimalToUTM.php //$latitude=46.05649434748774; //$longitude=14.588609055128277; if (($longitude != "")&($latitude != "")) { $longitude=1*$longitude; $latitude=1*$latitude; //echo "Input
fi = 46.05649434748774
"; //echo "lam = 14.588609055128277
"; //echo "GK N = 5101419.3
"; //echo "GK E = 5468171.8
"; $xy=convertDecimalToUTM($latitude,$longitude); echo "Sledijo rezuktati v WGS84:
N_northing= $xy[northing] [m]
E_easting= $xy[easting] [m]
Zone= $xy[zone]
utmLetter=$xy[utmLetter]
"; //print " N= $xy[northing]"; print "
scale factor = 0.9996"; } ?>