[Mapserver-users] ProjectionObj UTM to LatLong - PHP

ANDREW WOOLEY AWOOLEY at mountainland.org
Thu Feb 26 06:53:03 PST 2004


Folks,

I am having a problem projecting a point.  I looked a the documentation
(http://mapserver.gis.umn.edu/doc/phpmapscript-class-guide.html#proj )
and basically copied it and modified for my own use.  

It works great when I go from State Plane to UTM.  I get the correct
results with no complaints.  Then, if I take the resulting UTM
coordinates (or the State Plane Coordinates) and try to convert to
LatLong, it complains like this:

Warning: MapServer Error in msSearchDiskTree(): in
/home/www/html/trailsmap2.phtml on line 38

I have pasted the code below and marked line 38 in the code.

function CalcCoords($utmx,$utmy)
{
//This function takes the clicked XY and converts it to UTM
global $map;
$projInObj = ms_newprojectionobj($map->GetProjection()); // This map is
State Plane Utah Central NAD 27
$projOutObj = ms_newprojectionobj("init=epsg:26712"); // UTM Zone 12N
NAD 27
$poPoint = ms_newpointobj();
$poPoint->setXY($utmx, $utmy);         
$poPoint->project($projInObj, $projOutObj);	
$utmx = $poPoint->x;
$utmy = $poPoint->y;
$poPoint->free();
$projInObj->free();
$projOutObj->free();

//Then to LAT LONG

$projInObj = ms_newprojectionobj("init=epsg:26712"); //UTM NAD 27 Zone
12N
$projOutObj = ms_newprojectionobj("init=epsg:4268"); //NAD 27 Lat Long
$poPoint = ms_newpointobj();
$poPoint->setXY($utmx, $utmy);         <<<<<< Line 38.
$poPoint->project($projInObj, $projOutObj); 
$lat = $poPoint->x;
$long = $poPoint->y;
$poPoint->free();
$projInObj->free();
$projOutObj->free();
...
}

I have tried to put "proj=latlong" like the docs say with the same
result.

Any help would be greatly appreciated. Oh, I am using version 3.6.5. 

Thanks for your time.

Andrew Wooley
GIS Coordinator
Mountainland Association of Governments
586 E 800 N
Orem, UT 84097
ph: 801.229.3844
email: awooley at mountainland.org



More information about the MapServer-users mailing list