Infrastructure Map Server Developer

Infrastructure Map Server Developer

Reply
Member
amantradev
Posts: 3
Registered: ‎06-25-2008
Message 1 of 1 (120 Views)

Polygon Digitize Issue

120 Views, 0 Replies
07-28-2008 04:00 AM
Hi All,

I am trying to Digitize a polygon and add it to existing Featuresource in mapguide 2009. I could able to digitize the polygon and add it usingFeatureService-->UpdateFeature. But I could not able to see the polygon added to the layer. Anybody please help me where i am doing mistake. Following is the code

string coordData = txtCat.Text;
coordData = coordData.Substring(0, coordData.Length - 1);
Array coord = coordData.Split(',');

for (int i = 0; i < coord.Length - 1; i++)
{
string xyVal = (string)coord.GetValue(i);
string[] xy = xyVal.Split(' ');
double pX = Convert.ToDouble ( xy.GetValue(0).ToString ());
double pY = Convert.ToDouble(xy.GetValue(1).ToString());
polyData.Add(geomFact.CreateCoordinateXY(pX,pY));


}


MgUserInformation UserInfo = new MgUserInformation(wsSession);
MgSiteConnection siteConn = new MgSiteConnection();
siteConn.Open(UserInfo);
MgResourceService wsRSService = (MgResourceService)(siteConn.CreateService(MgServiceType.ResourceService));
//MgMappingService wsMap = (MgMappingService)(siteConn.CreateService(MgServiceType.MappingService));
MgFeatureService wsFeatService = (MgFeatureService)(siteConn.CreateService(MgServiceType.FeatureService));
//string mapRes = "Library://India/Hyderabad/Floor_1/Data/WS.FeatureSource";
//MgResourceIdentifier mgMapRes = new MgResourceIdentifier(mapRes);
//map = new MgMap();
//map.Create(wsRSService, mgMapRes, "Floor1_Map");

try
{

string wsFeatSource = "Library://Australia/Perth/Floor_1/Data/WS.FeatureSource";

MgResourceIdentifier wsRSIdentifier = new MgResourceIdentifier(wsFeatSource);
Boolean featSourceExist = false;
featSourceExist = DoesResourceExist(wsRSIdentifier, wsRSService);
if (featSourceExist)
{
MgPropertyCollection propColl = new MgPropertyCollection();
MgStringProperty strProp = new MgStringProperty("NAME", "POLY A");
propColl.Add(strProp);

MgWktReaderWriter wkReadWrite = new MgWktReaderWriter();
MgAgfReaderWriter agfReadWrite = new MgAgfReaderWriter();

MgLinearRing pExterior = geomFact.CreateLinearRing(polyData);


MgPolygon newPoly = geomFact.CreatePolygon (pExterior,null);

MgByteReader byteReader = agfReadWrite.Write(newPoly);

propColl.Add (new MgStringProperty ("Test","Test" ));

propColl.Add (new MgGeometryProperty ("SHPGEOM",byteReader));

MgFeatureCommandCollection featCmd = new MgFeatureCommandCollection();
featCmd.Add (new MgInsertFeatures ("Poly",propColl ));
wsFeatService.UpdateFeatures(wsRSIdentifier, featCmd, false);



}


}
catch
{

}

Thanks
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.