[mapguide-users] OnPointDigitized and GetTransform
Steve G
steve.golden at morganhill.ca.gov
Tue Feb 3 14:47:23 EST 2009
I have searched through the Nabble forum to find some sample codes, so I kind
of understand what you mean. However, I have also found that
MgCoordinateSystemTransform is now an abstract class. I have modified the
code to what I think would work:
$coordSysFactory = new MgCoordinateSystemFactory();
// Define a Target Coordinate System
$source = $coordSysFactory->Create($mapGetMapSRS());
// Define a Target Coordinate System
$LLWGS84 ='PROJCS["LL-WGS84",
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223563]],
AUTHORITY["EPSG","6326"]]
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]';
$source = $coordSysFactory->Create($map->GetMapSRS());
$target = $coordSysFactory->Create($LLWGS84);
$transform = new MgCoordinateSystemTransform($source, $target);
And then the following code with the digitizepoint function.
function DigitizePoint() {
// ShowResults("");
parent.parent.mapFrame.DigitizePoint(OnPointDigitized);
}
function OnPointDigitized(point) {
ShowResults("X: " + point.X + ", Y: " + point.Y);
However, I am not sure how to combine the two code snipets into one PHP
file? You said something about "call Transform() passing in your digitized
points", can you explain a little more or perhaps showing me how this would
be written in the code? Just having some difficulties with my limited
understanding and programming background. Thanks again!!!
Also, does anyone know if the Web Mercator Projection works?:
http://www.sharpgis.net/post/2008/05/15/SphericalWeb-Mercator-EPSG-code-3785.aspx
-Steve
Jackie Ng wrote:
>
> GetTransform() requires two MgCoordinateSystem objects. These are created
> from the MgCoordinateSystemFactory, which you have to pass in wkt strings
> of the coordinate systems.
>
> So you need 2 wkt strings:
>
> 1) The map's coordinate system (The GetMapSRS() method of MgMap will
> return this string)
> 2) The WGS84 coordinate system (You'll have to find this string yourself)
>
> Then with the MgCoordinateSystemTransform object obtained from
> GetTransform(), call Transform() passing in your digitized points, which
> will then return the transformed points (in WGS84)
>
> - Jackie
>
>
> Steve G wrote:
>>
>> I am trying to create a tool in the task pane where you click a button
>> and then click on the map which will get the x, y coordinates and open in
>> google maps. I have found the sample onpointdigitized php example and
>> copied the code and it works pretty well to get the x, y coordinates.
>> The next step is that my map is in state plane california III (feet)
>> projection, so the map units (feet) do not correlate to google maps
>> (WGS84, decimal degrees). I know there is the GetTransform() function,
>> but I haven't been able to figure out how to implement the code (put it
>> all together with the onpointdigitized). I was wondering if anyone could
>> provide some help. It's basically joining the two together and then
>> sending the code to google maps (I already got an API key).
>>
>> Any help would greatly be appreciated (I am more of a GIS user than
>> programmer)!
>>
>> Thanks,
>>
>> -Steve
>>
>
>
--
View this message in context: http://n2.nabble.com/OnPointDigitized-and-GetTransform-tp2261216p2265241.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list