[mapguide-users] OnPointDigitized and GetTransform

Mark Pendergraft markp at Meadgilman.com
Tue Feb 3 14:58:04 EST 2009


I have a utility that accomplishes what you are trying to do, and I
convert to lat/long using this code snippet (in vb.net)
Assume you have variables X,Y which are doubles.

        Dim geoFact As New MgGeometryFactory
        Dim coord As MgCoordinate = geoFact.CreateCoordinateXY(X, Y)
                
        Dim coordFact As New MgCoordinateSystemFactory
        Dim coordSys As MgCoordinateSystem      
        coordSys = coordFact.Create(Map.GetMapSRS)
        
        Dim LLcoord As MgCoordinate = coordSys.ConvertToLonLat(coord)

	  link = "http://maps.google.com?q=" + LLcoord.Y.ToString + ","
+ LLcoord.X.ToString

I hope that helps.
Also, you don't really need an API key to do this.  My function just
puts together a link, and then uses javascript to open it in a new
window.

-Mark P.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Steve G
Sent: Tuesday, February 03, 2009 11:47 AM
To: mapguide-users at lists.osgeo.org
Subject: Re: [mapguide-users] OnPointDigitized and GetTransform


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.

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users


More information about the mapguide-users mailing list