[mapguide-users] Re: Is it possible to convert Lat and Long value
to X Y (AJAX viewer)
Greg
gbneff at cid.utah.gov
Fri Feb 25 15:20:32 EST 2011
I was able to do it using something Like this:
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgMap map = new MgMap();
map.Open(resService, "Cid_Map");
//create coord sys
MgCoordinateSystemFactory coordFactory = new
MgCoordinateSystemFactory();
String srsMapDef = map.GetMapSRS().ToString();
MgCoordinateSystem mapCS = coordFactory.Create(srsMapDef);
MgGeometryFactory geometryFactory = new MgGeometryFactory();
MgCoordinate coordLatLon;
MgCoordinate coordXY;
ArrayList X = new ArrayList();
ArrayList Y = new ArrayList();
Response.Write("<table>");
for (i = 0; i < lat.Count; i++)
{
coordLatLon =
geometryFactory.CreateCoordinateXY(Convert.ToDouble(lon[i]),
Convert.ToDouble(lat[i]));
coordXY = mapCS.ConvertFromLonLat(coordLatLon);
X.Add(coordXY.GetX().ToString());
Y.Add(coordXY.GetY().ToString());
if (i < 108)
{
Response.Write("<tr class='colData'><td>" + X[i] +
"</td><td>" + Y[i] + "</td></tr>");
}
}
Response.Write("</table>");
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Is-it-possible-to-convert-Lat-and-Long-value-to-X-Y-AJAX-viewer-tp6023213p6065880.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list