[mapguide-users] converting projection on fly
shreepad
shreepadr at valuecad.com
Tue Jun 5 17:15:49 EDT 2007
nevermind i sloved it.
my code was missing somethign
here is the correced code
string ss = map.GetMapSRS();
MgCoordinateSystemFactory coordinateSystemFactory = new
MgCoordinateSystemFactory();
MgCoordinateSystem srs = coordinateSystemFactory.Create(ss);
MgCoordinateSystemMeasure srsMeasure = new
MgCoordinateSystemMeasure(srs);
double X = 6144744.38401563; (just sample x ,y point but you can add
dynamic point from map)
double Y = 2100980.15175119;
MgGeometryFactory gFactory = new MgGeometryFactory();
MgCoordinate coord = gFactory.CreateCoordinateXY(X, Y);
MgCoordinate newCoord = srs.ConvertToLonLat(coord);
double xConv = newCoord.GetX();
double yConv = newCoord.GetY();
Response.Write(xConv);
Response.Write(yConv);
h
shreepad wrote:
>
> Hi
> i have the data in state plane coordinate and i want to convert them to
> lat lon on fly i have wrote the code but it is giving me error. here is my
> code. please let me know what i am doing wrong .
>
> projection is NAD_1983_StatePlane_California_III_FIPS_0403_Feet
> and i want to conver it to LAT LON
>
> here is my code
>
>
> MgSelection mapSelection = null;
> MgResourceService resService =
> (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
> MgFeatureService featService =
> (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
> MgMap map = new MgMap();
> map.Open(resService, "General Public Map");
> mapSelection = new MgSelection(map);
> mapSelection.Open(resService, "General Public Map");
> MgReadOnlyLayerCollection layers = mapSelection.GetLayers();
>
>
> MgCoordinateSystemFactory l_oMGCoordinateSystemFactory = new
> MgCoordinateSystemFactory();
> MgGeometryFactory l_oMGGeometryFactory = new MgGeometryFactory();
> String l_sWKTproj = map.GetMapSRS();
>
> Response.Write(l_sWKTproj);
> MgCoordinateSystem l_oMGCoordinateSystem =
> l_oMGCoordinateSystemFactory.Create(l_sWKTproj);
>
> double l_dMinX = 6141861.7828919375;
> double l_dMinY = 2095968.7307088032;
>
> MgCoordinate l_oMGCoordinateLatLonLL =
> l_oMGGeometryFactory.CreateCoordinateXY(l_dMinX, l_dMinY);
> MgCoordinate l_oMGCoordinateXYLL =
> l_oMGCoordinateSystem.ConvertToLonLat(l_oMGCoordinateLatLonLL);
>
> double xConv = l_oMGCoordinateXYLL.GetX();
> double yConv = l_oMGCoordinateXYLL.GetY();
> Response.Write(xConv);
> Response.Write(yConv);
>
> "
>
>
--
View this message in context: http://www.nabble.com/converting-projection-on-fly-tf3873611s16610.html#a10977904
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list