stmusiclover

How to add stops in the stops layer in network analysis?

Discussion created by stmusiclover on Oct 31, 2011
I have got the featureclass of stops layer via following code:
          
            IFeatureClass fc = null;
            IFeatureCursor cursor = null;
            IFeature f = null;
            IFeatureBuffer fbuffer = null;
            fc = m_NAContext.NAClasses.get_ItemByName("Stops") as IFeatureClass;

And then I add some feature as stops in this featureclass, it indeed add some point featture int the stops layer, but all those point are unlocated, even I change the value of SnapTolerance. So how can I fix that? Any answer would be appreciated!

More codes I used are as follows:


            m_NAContext.Locator.SnapTolerance = 5000;
            m_NAContext.Locator.SnapToleranceUnits = ESRI.ArcGIS.esriSystem.esriUnits.esriMeters;
           
            IFeatureClass fc = null;
            IFeatureCursor cursor = null;
            IFeature f = null;
            IFeatureBuffer fbuffer = null;


            fc = m_NAContext.NAClasses.get_ItemByName("Stops") as IFeatureClass;
           
            IWorkspace workspace = null;
            IWorkspaceEdit workspaceEdit = null;
            workspace=(fc as IDataset).Workspace;
            workspaceEdit=workspace as IWorkspaceEdit;
            workspaceEdit.StartEditing(false);
            workspaceEdit.StartEditOperation();
            IPoint p = null;

            cursor = fc.Insert(true);
            fbuffer=fc.CreateFeatureBuffer();
            f = (IFeature)fbuffer;

            p = new PointClass();
            p = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(62,100);

            f.Shape = p;

            cursor.InsertFeature(fbuffer);

            cursor = fc.Insert(true);
            fbuffer = fc.CreateFeatureBuffer();
            f = (IFeature)fbuffer;

            p = new PointClass();
            p = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(128, 128);

            f.Shape = p;

            cursor.InsertFeature(fbuffer);

            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            axMapControl1.Refresh();

Outcomes