Infrastructure Map Server Developer

Infrastructure Map Server Developer

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

Polygon Digitize Issue

116 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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.