• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Autodesk MapGuide Developer

    Reply
    Member
    Posts: 3
    Registered: ‎06-25-2008

    Polygon Digitize Issue

    105 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
    Please use plain text.