[mapguide-users] Reprojecting Data in PHP - PROJ4 failed to transform the data.

passionlessDrone ScottB at talgov.com
Wed Jun 13 09:28:44 EDT 2007


Hello friends - 

Mapguide Enterprise / Postgres/PostGIS backend / PHP Web environment.  I'm
relatively new to the GIS world and kind of got thrown into mix without much
(any) background, so hopefully this doesn't come off as too ignorant.  

For whatever reason, OGR filtering on a layer against PostGIS won't go; so I
am attempting to get lat / long from my points table directly, create a
point object for each, create a new layer, and push the layer into the map,
refresh the pane and go.  This all works; however, the points don't show up
anywhere close to where they 'should' be.  I have confidence the lat / longs
are accurate and this is a projection / coordinate system issue; if I push
these points into ArcMap, or perform a transform on them in FME and then
into a layer, they DO show up where they are expected to be.  For our
business process however, I need to only show a subset of of these points;
dynamically determined at runtime.  

I grabbed some sample code from this site and the Map Guide development
guide that describes a mechanism by which I can reproject the data from
llwgs84 to north florida plains via php calls.  [This is the same operation
being performed in FME to get the points to show up 'right'].  Tragically,
upon calling the transform method, I get a pretty vague error message:

"The coordinate system transform failed.  PROJ4 failed to transform the
data. "

Is there any way I can get more verbose information as to what is going
wrong?  

I'm attaching my souce code below.  Any insight is appreciated!

- pD

******************************************************************************
// CODE ABOVE CREATES A LAYER, DEFINES THE POINTS, AND ADDS THEM THE TO THE
LAYER .....

	// BEFORE ADDING THE LAYER TO THE MAP, WE WILL ATTEMPT TO 'REPROJECT IT'
	$coordSysFactory = new MgCoordinateSystemFactory();

	// DEFINE A SOURCE NAD
	$llwgs84 ='PROJCS["LL-WGS84", GEOGCS["WGS84 Lat/Longs, Degrees, -180 ==>
+180",DATUM["WGS_1984",SPHEROID["World Geodetic System of
1984",6378137,298.257223563],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]]';


	// define a destination NAD!
	$northFlorida ='PROJCS["NAD83 Florida State Planes, Northern Zone, Meter",
   					GEOGCS["North_American_Datum_1983",
       				DATUM["North_American_Datum_1983",
           			SPHEROID["Geodetic Reference System of
1980",6378137,298.2572221009113],
           			AUTHORITY["EPSG","6269"]],
       				PRIMEM["Greenwich",0],
       				UNIT["degree",0.0174532925199433]],
					   PROJECTION["Lambert_Conformal_Conic_2SP"],
					   PARAMETER["standard_parallel_1",30.75],
					   PARAMETER["standard_parallel_2",29.5833333333333],
					   PARAMETER["latitude_of_origin",29],
					   PARAMETER["central_meridian",-84.5],
					   PARAMETER["false_easting",600000],
					   PARAMETER["false_northing",0],
					   UNIT["METER",1]]';

	// CREATE SOME OBJECTS.  I REALLY DON'T KNOW WHAT THEY ARE, BUT THE EXAMPLE
I
	// STOLE FROM THE INTERNET DOES THIS.  
	$source = $coordSysFactory->Create($llwgs84);
	$target = $coordSysFactory->Create($northFlorida);
	//$target = $coordSysFactory->Create($map->GetMapSRS());

// WE DON'T WANT TO SELECT A SUBSET HERE, BUT CREATION OF A READER SEEMS TO
INSIST ON GETTING 
	// A QUERY OBJECT, SO CREATE AN EMPTY ONE. 
	$bogusQuery = new MgFeatureQueryOptions();
	$bogusQuery->SetFilter("");
	
	// CREATE THE TRANSFORMER
	$transform = new MgCoordinateSystemTransform($source, $target);

	$featureReader = $featureService->SelectFeatures($resourceIdentifier,
"Points", $bogusQuery);

	while ($featureReader->ReadNext())
	{
		$byteReader = $featureReader->GetGeometry('GEOM');
		$geometryReaderWriter = new MgAgfReaderWriter();

		$geometry = $geometryReaderWriter->Read($byteReader);

   		$geometry = $geometry->Transform($transform);

		// $area = $geometry->GetArea()');

	}// end while


....
// DO THE REST OF THE STUFF LIKE ADDING THE LAYER TO THE MAP. 

-- 
View this message in context: http://www.nabble.com/Reprojecting-Data-in-PHP---PROJ4-failed-to-transform-the-data.-tf3914641s16610.html#a11099322
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list