Beispiel #1
0
        private double GetEndElevation(IFeatureLayer pDepthSoundings, IFeatureLayer pLineLayer, IFeature pLineFeature, string strDepthField)
        {
            try
            {
                IEnvelope pCombinedEnvelope = CombineExtents(pDepthSoundings.FeatureClass, pLineLayer.FeatureClass);

                IPointCollection4 pPointColl = pLineFeature.Shape as IPointCollection4;
                IPoint            ppoint     = new PointClass();


                //Get the last point on the line
                ppoint = pPointColl.get_Point(-1);

                IFeatureCursor pDepthCursor = pDepthSoundings.Search(null, false);
                IFeatureIndex2 pFtrInd      = new FeatureIndexClass();
                pFtrInd.FeatureClass  = pDepthSoundings.FeatureClass;
                pFtrInd.FeatureCursor = pDepthCursor;
                pFtrInd.Index(null, pCombinedEnvelope);
                IIndexQuery2 pIndQry = pFtrInd as IIndexQuery2;

                int    FtdID     = 0;
                double dDist2Ftr = 0;
                pIndQry.NearestFeature(ppoint, out FtdID, out dDist2Ftr);

                IFeature pCloseFeature = pDepthSoundings.FeatureClass.GetFeature(FtdID);
                return(Convert.ToDouble(pCloseFeature.get_Value(pCloseFeature.Fields.FindField(strDepthField))));
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                return(0);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="pCol">for a polygon, the fisrt point and the last point are identical</param>
 /// <param name="dblFactor"></param>
 /// <returns></returns>
 public static IEnumerable <CPoint> GetCptEbByICol(IPointCollection4 pCol)
 {
     for (int i = 0; i < pCol.PointCount; i++)
     {
         yield return(new CPoint(i, pCol.get_Point(i)));
     }
 }
 private void SetZToZero(IPointCollection4 pCol)
 {
     for (int i = 0; i < pCol.PointCount; i++)
     {
         IPoint copyipt = pCol.get_Point(i);
         copyipt.Z = 0;
         pCol.UpdatePoint(i, copyipt);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="pCol"></param>
 /// <remarks>note that if we set z coordinates, then we may lose many information related to IPolygon
 /// (ConnectedComponentBag, InteriorRingBag, ExteriorRingBag, etc.) </remarks>
 public static void SetZCoordinates(IPointCollection4 pCol)
 {
     for (int i = 0; i < pCol.PointCount; i++)
     {
         IPoint copyipt = pCol.get_Point(i);
         copyipt.Z = 0;
         pCol.UpdatePoint(i, copyipt);
     }
 }
        //public virtual CGeoBase Copy()
        //{
        //    return null;

        //}

        /// <summary>
        /// this funcation can only be used for a shape that implements IPointCollection4
        /// </summary>
        public virtual void JudgeAndSetZToZero()
        {
            IPointCollection4 pCol = _pGeo as IPointCollection4;

            if (pCol.PointCount > 0)
            {
                IPoint ipt0 = pCol.get_Point(0);
                if (double.IsNaN(ipt0.Z))
                {
                    SetZToZero(pCol);
                }
            }
        }
        public IPointCollection4 modify1VertexOfAPolyline(IGeometryCollection geo, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            Double   hitDistance = 0; Int32 hitPartIndex = 0;
            Int32    hitSegmentIndex = 0;
            Boolean  rightSide       = false;
            IHitTest hitTest         = (IHitTest)geo;
            Boolean  foundGeometry   = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry         geometry        = geo.get_Geometry(hitPartIndex);
                IPointCollection4 pointCollection = (IPointCollection4)geometry;
                IPoint            transformPoint  = pointCollection.get_Point(hitSegmentIndex);
                ITransform2D      transform2D     = (ITransform2D)transformPoint;
                transform2D.Move(offsetX, offsetY);
                pointCollection.UpdatePoint(hitSegmentIndex, transformPoint);
                return(pointCollection);
            }
            return(null);
        }
        private void DWIntersect(CPolyline pBSCpl, ref List <CPoint> cptlt, double dblIgnorableDis)
        {
            IPointCollection4 pCol = new PolylineClass();

            for (int i = 0; i < cptlt.Count; i++)
            {
                cptlt[i].SetPoint();
                pCol.AddPoint(cptlt[i].pPoint);
            }
            IPolyline5 ipl = pCol as IPolyline5;

            pBSCpl.SetPolyline();
            IRelationalOperator pRel = pBSCpl.pPolyline as IRelationalOperator;
            bool isCrosses           = pRel.Crosses(ipl);

            if (isCrosses == true)
            {
                ITopologicalOperator pTop          = pBSCpl.pPolyline as ITopologicalOperator;
                IGeometry            pGeoIntersect = pTop.Intersect(ipl, esriGeometryDimension.esriGeometry0Dimension);
                IPointCollection4    pColIntersect = pGeoIntersect as IPointCollection4;

                double dblMaxDis = 0;
                for (int j = 0; j < pColIntersect.PointCount; j++)
                {
                    double dblDis = CGeoFunc.CalDistanceFromStartPoint(ipl, pColIntersect.get_Point(j), false);
                    if (dblDis > dblMaxDis)
                    {
                        dblMaxDis = dblDis;
                    }
                }

                ICurve pSubCurve;
                ipl.GetSubcurve(dblMaxDis, ipl.Length, false, out pSubCurve);
                //IPolyline5 Cutipl = pSubCurve as IPolyline5;
                IPointCollection4 iplCutCol = pSubCurve as IPointCollection4;

                //the new first segment
                IPointCollection4 pSegCol = new PolylineClass();
                pSegCol.AddPoint(ipl.FromPoint, _Missing, _Missing);
                pSegCol.AddPoint(iplCutCol.get_Point(1), _Missing, _Missing);
                IPolyline5 seg = pSegCol as IPolyline5;
                bool       isCrossesSeg;

                int intIndex = 0;
                while (intIndex < iplCutCol.PointCount - 1)
                {
                    intIndex++;
                    pSegCol.UpdatePoint(1, iplCutCol.get_Point(intIndex));
                    isCrossesSeg = pRel.Crosses(seg);
                    if (isCrossesSeg == false)
                    {
                        iplCutCol.RemovePoints(1, intIndex - 1);
                        iplCutCol.UpdatePoint(0, ipl.FromPoint);
                        break;
                    }
                    if (seg.Length >= dblIgnorableDis)
                    {
                        double dblOriginalIntersectionDis  = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, pCol.get_Point(0), false);
                        double dblRealisticIntersectionDis = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, iplCutCol.get_Point(0), false);

                        IPointCollection4 pColBSCpl = pBSCpl.pPolyline as IPointCollection4;
                        double            dblSumDis = 0;
                        for (int i = 0; i < pColBSCpl.PointCount - 1; i++)
                        {
                            double dblDis = CGeoFunc.CalDis(pColBSCpl.get_Point(i), pColBSCpl.get_Point(i + 1));
                            dblSumDis += dblDis;
                            if (dblSumDis >= dblRealisticIntersectionDis)
                            {
                                double dblDisPre   = Math.Abs(dblSumDis - dblDis - dblOriginalIntersectionDis);
                                double dblDisNext  = Math.Abs(dblSumDis - dblOriginalIntersectionDis);
                                IPoint intersectpt = new PointClass();
                                if (dblDisPre <= dblDisNext)
                                {
                                    intersectpt = pColBSCpl.get_Point(i);
                                }
                                else
                                {
                                    intersectpt = pColBSCpl.get_Point(i + 1);
                                }
                                iplCutCol.UpdatePoint(0, intersectpt);
                                break;
                            }
                        }
                        break;
                    }
                }
                cptlt = CHelpFunc.GetCptEbByICol(iplCutCol).ToList();
            }
        }
        public void GeneratePoints2(string sLineLayer, string sDepthPointsLayer, double dblInterval, string strDepthField)
        {
            try
            {
                IMxDocument pmxdoc = ArcMap.Document as IMxDocument;
                IMap        pmap   = pmxdoc.FocusMap;

                IFeatureLayer pDepthSoundings = FindLayer(pmap, sDepthPointsLayer) as IFeatureLayer;
                IFeatureLayer pLineLayer      = FindLayer(pmap, sLineLayer) as IFeatureLayer;
                IFeatureLayer pOutpoints      = new FeatureLayerClass();
                pOutpoints.FeatureClass = MakePointFC();
                pOutpoints.Name         = "Output Points";
                ArcMap.Document.ActiveView.FocusMap.AddLayer(pOutpoints);

                IProgressDialog2 pProgressDialog = ShowProgressIndicator("Calculating...", pLineLayer.FeatureClass.FeatureCount(null), 1);
                pProgressDialog.ShowDialog();

                //Set up the Outpoints cursor
                IFeatureCursor pFCurOutPoints = pOutpoints.Search(null, false);
                pFCurOutPoints = pOutpoints.FeatureClass.Insert(true);

                //Set up the LineLayer Cursor
                IFeatureCursor pFCur        = pLineLayer.Search(null, false);
                IFeature       pLineFeature = pFCur.NextFeature();

                IFeatureBuffer pFBuffer = pOutpoints.FeatureClass.CreateFeatureBuffer();

                ICurve pCurve;
                IPoint ppoint;

                int    iLineProgressCount         = 1;
                double dblDistance                = 0;
                double dblTotalDistanceCalculated = 0;
                double iNumIntervals              = 0;
                double dblElevationDiff           = 0;
                double dblElevationInterval       = 0;
                double dblElevation               = 0;
                double dlbStartElevation          = 0;
                double dblEndElevation            = 0;

                pProgressDialog.Description = "Generating points for Line: " + iLineProgressCount + " of " + pLineLayer.FeatureClass.FeatureCount(null).ToString();

                while (pLineFeature != null)
                {
                    int iStartVertex = 0;
                    int iEndVertex   = 1;
                    //Get the vertices of the line feature
                    IPointCollection4 pPointColl = pLineFeature.Shape as IPointCollection4;


                    //loop thru the vertices
                    for (int i = 0; i <= pPointColl.PointCount - 1; i++)
                    {
                        IPoint pStartPoint = pPointColl.get_Point(iStartVertex);
                        IPoint pEndPoint   = pPointColl.get_Point(iEndVertex);
                        //Make an intermediate line segment between each set of vertices
                        IPath pPath = MakePath(pStartPoint, pEndPoint);

                        //Get the starting elevation from the depth point layer
                        dlbStartElevation = GetPointElevation(pDepthSoundings, pLineLayer, pStartPoint, strDepthField);
                        dblElevation      = dlbStartElevation;
                        IPointCollection pPointForPath = null;
                        //Get the ending elevation from the next vertex
                        pEndPoint       = pPointColl.get_Point(iEndVertex);
                        dblEndElevation = GetPointElevation(pDepthSoundings, pLineLayer, pEndPoint, strDepthField);
                        //If the returned elevation is 0, then there is no coincident depth point, move to the next vertex for your endpoint
                        if (dblEndElevation == 0)
                        {
                            //IPointCollection reshapePath = new PathClass();
                            object missing = Type.Missing;
                            pPointForPath = new PathClass();
                            pPointForPath.AddPoint(pStartPoint, ref missing, ref missing);
                            while (dblEndElevation == 0)
                            {
                                pEndPoint       = pPointColl.get_Point(iEndVertex);
                                dblEndElevation = GetPointElevation(pDepthSoundings, pLineLayer, pEndPoint, strDepthField);


                                pPointForPath.AddPoint(pEndPoint, ref missing, ref missing);
                                //pLineSegment.Reshape(reshapePath as IPath);

                                if (dblEndElevation != 0)
                                {
                                    break;
                                }
                                iEndVertex++;
                            }
                        }

                        if (pPointForPath != null)
                        {
                            pPath = pPointForPath as IPath;
                        }



                        //number of line segments based on the user's interval
                        iNumIntervals    = Convert.ToDouble(pPath.Length / dblInterval);
                        dblElevationDiff = dblEndElevation - dlbStartElevation;

                        //The calculated elevation interval to step up each time
                        dblElevationInterval = dblElevationDiff / iNumIntervals;


                        ppoint = new PointClass();

                        while (dblTotalDistanceCalculated <= pPath.Length)
                        {
                            pFBuffer.set_Value(pFBuffer.Fields.FindField("LineOID"), pLineFeature.OID);
                            pFBuffer.set_Value(pFBuffer.Fields.FindField("Distance"), Math.Round(dblDistance, 4));
                            pFBuffer.set_Value(pFBuffer.Fields.FindField("Elevation"), Math.Round(dblElevation, 4));


                            //this code set the point on the line at a distance
                            pPath.QueryPoint(0, dblDistance, false, ppoint);



                            pFBuffer.set_Value(pFBuffer.Fields.FindField("X"), ppoint.X);
                            pFBuffer.set_Value(pFBuffer.Fields.FindField("Y"), ppoint.Y);

                            //reCalc the new distance and elevation values for the next iteration
                            dblDistance = dblDistance + dblInterval;
                            dblTotalDistanceCalculated = dblTotalDistanceCalculated + dblInterval;

                            //Insert the feature into the featureclass
                            pFBuffer.Shape = ppoint;

                            if (!IsPointCoincident(ppoint, pOutpoints))
                            {
                                pFCurOutPoints.InsertFeature(pFBuffer);
                            }


                            if (dblTotalDistanceCalculated >= pPath.Length)
                            {
                                break;
                            }

                            dblElevation = dblElevation + dblElevationInterval;
                        }



                        //start the next line segment at the end of last one
                        iStartVertex = iEndVertex;
                        //look to the next vertex for the new ending point
                        iEndVertex++;


                        if (iEndVertex == pPointColl.PointCount)
                        {
                            ////if its the last vertex of the last line, add a point
                            //pFBuffer.Shape = pPath.ToPoint;
                            //pFBuffer.set_Value(pFBuffer.Fields.FindField("LineOID"), pLineFeature.OID);
                            //pFBuffer.set_Value(pFBuffer.Fields.FindField("Distance"), Math.Round(dblDistance, 4));
                            //pFBuffer.set_Value(pFBuffer.Fields.FindField("Elevation"), Math.Round(dblElevation, 4));
                            //pFBuffer.set_Value(pFBuffer.Fields.FindField("X"), pPath.ToPoint.X);
                            //pFBuffer.set_Value(pFBuffer.Fields.FindField("Y"), pPath.ToPoint.Y);
                            //pFCurOutPoints.InsertFeature(pFBuffer);

                            //Reset the distance values back to 0 for the next feature
                            dblDistance = 0;
                            dblTotalDistanceCalculated = 0;
                            pStepProgressor.Step();
                            iLineProgressCount++;
                            pPath.SetEmpty();
                            break;
                        }


                        //Reset the distance values back to 0 for the next feature
                        dblDistance = 0;
                        dblTotalDistanceCalculated = 0;
                        //pLineFeature = pFCur.NextFeature();
                        pStepProgressor.Step();
                        //pProgressDialog.Description = "Generating points for Line: " + iLineProgressCount + " of " + pLineLayer.FeatureClass.FeatureCount(null).ToString();
                        iLineProgressCount++;
                        pPath.SetEmpty();
                    }
                    pLineFeature = pFCur.NextFeature();
                }



                //cleanup
                pFCurOutPoints.Flush();
                pFCur.Flush();
                pProgressDialog.HideDialog();
                pmxdoc.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
            }
        }
        public override void OnClick()
        {
            try
            {
                //setup a file stream and a stream writer to write out the addresses that do not have a nearby street or a street out of range
                string path = @"C:\temp\DeleteDupVerts" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm") + ".txt";
                System.IO.FileStream fileStream   = new System.IO.FileStream(path, FileMode.Create);
                StreamWriter         streamWriter = new StreamWriter(fileStream);
                streamWriter.WriteLine("UniqueID" + "," + "FeatureOID" + "," + "VertIndex1" + "," + "VertIndex2");
                int  intUniqueID = 0;
                bool updatePreviousPnt;
                int  numberOfVerticesRemovedFromPntCollection;
                int  vertexIndexToRemove;

                // get access to the current arcmap variables
                clsPushSgidStaticClass.GetCurrentMapDocVariables();

                // show the cursor as busy
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                clsGlobals.pGFlayer     = null;
                clsGlobals.arcFeatLayer = null;
                IFeatureLayer arcFeatureLayerVertPnts = null;
                IFeatureClass arcFeatureClassVertPnts = null;
                //var listOfIndexesToRemove = new List<Int32>();

                // loop through the map's layers and check for the layer with the targeted name
                for (int i = 0; i < clsGlobals.pMap.LayerCount; i++)
                {
                    if (clsGlobals.pMap.Layer[i].Name == "REMOVE_DUP_VERTS")
                    {
                        clsGlobals.pGFlayer     = (IGeoFeatureLayer)clsGlobals.pMap.Layer[i];
                        clsGlobals.arcFeatLayer = (IFeatureLayer)clsGlobals.pMap.Layer[i];
                    }

                    if (clsGlobals.pMap.Layer[i].Name == "VERT_PNTS")
                    {
                        arcFeatureLayerVertPnts = (IFeatureLayer)clsGlobals.pMap.Layer[i];
                        arcFeatureClassVertPnts = arcFeatureLayerVertPnts.FeatureClass;
                    }
                }

                // make sure the user is editing
                //get the editor extension
                UID arcUID = new UID();
                arcUID.Value         = "esriEditor.Editor";
                clsGlobals.arcEditor = clsGlobals.arcApplication.FindExtensionByCLSID(arcUID) as IEditor3;

                // check if editing first
                if (clsGlobals.arcEditor.EditState == ESRI.ArcGIS.Editor.esriEditState.esriStateNotEditing)
                {
                    MessageBox.Show("You must be editing in order to remove duplicate vertices.", "Must Be Editing",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                IDataset       arcDataset       = (IDataset)clsGlobals.arcFeatLayer;
                IWorkspace     arcWorkspace     = arcDataset.Workspace;
                IWorkspaceEdit arcWorkspaceEdit = (IWorkspaceEdit)arcWorkspace;

                // make sure we're editing the correct workspace
                if (!(arcWorkspaceEdit.IsBeingEdited()))
                {
                    MessageBox.Show("You must be editing the REMOVE_DUP_VERTS layer in order to proceed.",
                                    "Must Be Editing", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // get access to the selected features in the user specified layer
                IDisplayTable arcDisplayTable = (IDisplayTable)clsGlobals.arcFeatLayer;
                ISelectionSet arcSelectionSet = arcDisplayTable.DisplaySelectionSet;

                // make sure there's at least one feature selected in the specified layer
                if (arcSelectionSet.Count == 0)
                {
                    MessageBox.Show(
                        "You must select at least one feature in the REMOVE_DUP_VERTS layer to spatially assign values to.",
                        "No Features are Selected.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // confirm the user wants to edit that layer's fields on the selected records
                DialogResult dialogResult =
                    MessageBox.Show(
                        "Would you like to proceed with editing " + arcSelectionSet.Count +
                        " features on the REMOVE_DUP_VERTS Layer, removing non-coincident verticies that are within 1 meter of eachother?",
                        "Confirm Edits", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Yes)
                {
                    // loop through the selected feature remove_dup_verts layer
                    IEnumIDs arcEnumIDs = arcSelectionSet.IDs;
                    int      iD;
                    while ((iD = arcEnumIDs.Next()) != -1)
                    {
                        vertexIndexToRemove = 0;
                        numberOfVerticesRemovedFromPntCollection = 0;

                        clsGlobals.arcFeatureToEditSpatial = clsGlobals.arcFeatLayer.FeatureClass.GetFeature(iD);
                        clsGlobals.arcEditor.StartOperation();

                        // Loop through this features verticies.
                        // Get the feature's geometry.
                        IGeometry arcEdit_geometry = clsGlobals.arcFeatureToEditSpatial.Shape;
                        IPolyline arcEdit_polyline = arcEdit_geometry as IPolyline;

                        // get a point collection
                        IPointCollection4 pointCollection = (IPointCollection4)arcEdit_polyline;
                        IPoint            currPoint       = null;
                        IPoint            previousPoint   = null;

                        // Iterate the point collection array (the first point is the start of the line and last is the end of the line).
                        // I added the numberOfVerticesRemovedFromPntCollection variable in order to preserve the initial point collection iterations (it's needed in order to loop through all the original vertices)
                        for (int i = 0; i < pointCollection.PointCount + numberOfVerticesRemovedFromPntCollection; i++)
                        {
                            // Reset the boolean value.
                            updatePreviousPnt = true;

                            // Reset the number of vertices removed to zero
                            //numberOfVerticesRemovedFromPntCollection = 0;
                            //vertexIndexToRemove = 0;

                            // Get the current point.
                            currPoint = null;
                            // This is the problem as it's setting the current i point, but this should be a reference to the original index
                            //currPoint = pointCollection.get_Point(i);
                            currPoint = pointCollection.get_Point(i - numberOfVerticesRemovedFromPntCollection);
                            //MessageBox.Show("X:" + currPoint.X + " , Y:" + currPoint.Y);

                            // Check if the previous point has been assigned yet (if not, it's the first itteration of this line segment)
                            if (previousPoint != null)
                            {
                                // Check the distance between the currPoint and previousPoint to see if it's less than 1 meter
                                IProximityOperator proximityOperator;
                                IGeometry          currGeometry     = currPoint;
                                IGeometry          previousGeometry = previousPoint;
                                proximityOperator = currGeometry as IProximityOperator;

                                // Check distance to the previous vertex.
                                double distBetweenCurrAndPrevPnt = proximityOperator.ReturnDistance(previousGeometry);

                                // Check if distance is less than 1 meter.
                                if (distBetweenCurrAndPrevPnt <= 3)
                                {
                                    //MessageBox.Show(distance.ToString() + " is less than 1 meter.");

                                    // Check if the the current point intersects any other vertices, before we delete it.
                                    // If it does, then check the current point to see if intersects any other vertices, before we delete it.
                                    ISpatialFilter spatialFilterCurr = new SpatialFilterClass();
                                    spatialFilterCurr.Geometry   = currGeometry;
                                    spatialFilterCurr.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                                    IFeatureCursor featureCursorCurr = arcFeatureClassVertPnts.Search(spatialFilterCurr, false);
                                    IFeature       featureCurr       = null;
                                    int            vertAtCurrPnt     = 0;

                                    while ((featureCurr = featureCursorCurr.NextFeature()) != null)
                                    {
                                        vertAtCurrPnt = vertAtCurrPnt + 1;
                                    }

                                    // Check if we can delete this vertex
                                    if (vertAtCurrPnt > 1)
                                    {
                                        // There's more than one vertex here at the current vertex/point, so we cant' delete it, check the the previous
                                        // now check the if we can delete the previous point (as we can't delete the current point b/c it is co-incident)
                                        ISpatialFilter spatialFilterPrev = new SpatialFilterClass();
                                        spatialFilterPrev.Geometry   = previousGeometry;
                                        spatialFilterPrev.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                                        IFeatureCursor featureCursorPrev = arcFeatureClassVertPnts.Search(spatialFilterPrev, false);
                                        IFeature       featurePrev       = null;
                                        int            vertsAtPrevPnt    = 0;

                                        while ((featurePrev = featureCursorPrev.NextFeature()) != null)
                                        {
                                            vertsAtPrevPnt = vertsAtPrevPnt + 1;
                                        }

                                        // Check if we can delete this vertex
                                        if (vertsAtPrevPnt > 1)
                                        {
                                            // can delete this one either, so log it in the text file so we can inspect it manual
                                            intUniqueID = intUniqueID + 1;
                                            streamWriter.WriteLine(intUniqueID + "," + clsGlobals.arcFeatureToEditSpatial.OID + "," + i + "," + Convert.ToString(i - 1));

                                            //MessageBox.Show("Can't Delete either vertex for this 1 meter duplicate.  Help!  Need a human!");
                                        }
                                        else
                                        {
                                            // Delete the previous vertex.

                                            // Add this index to the list of
                                            //listOfIndexesToRemove.Add(i);

                                            vertexIndexToRemove = i - numberOfVerticesRemovedFromPntCollection;

                                            // test replacing the point collection before we do anything with it
                                            //pointCollection.ReplacePointCollection(0,pointCollection.PointCount,pointCollection);
                                            //MessageBox.Show("before remove: " + pointCollection.PointCount);
                                            // Remove the point from the collection.
                                            //pointCollection.RemovePoints(i - 1, 1);
                                            pointCollection.RemovePoints(vertexIndexToRemove - 1, 1);
                                            //MessageBox.Show("after remove: " + pointCollection.PointCount);

                                            // Increment the total number of vertices removed
                                            numberOfVerticesRemovedFromPntCollection =
                                                numberOfVerticesRemovedFromPntCollection + 1;
                                            // reset the point collection, now that the point has been removed
                                            //pointCollection.ReplacePointCollection(i, i - pointCollection.PointCount, pointCollection);

                                            // Replace the features shape with the newly modified point collection.
                                            //clsGlobals.arcFeatureToEditSpatial.Shape = pointCollection as IGeometry;
                                            //clsGlobals.arcFeatureToEditSpatial.Store();
                                        }

                                        // release the feature cursor
                                        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursorPrev);
                                    }
                                    else
                                    {
                                        // Delete the current vertex
                                        // Add this index to the list of
                                        //listOfIndexesToRemove.Add(i);

                                        vertexIndexToRemove = i - numberOfVerticesRemovedFromPntCollection;

                                        // test replacing the point collection before we do anything with it
                                        //pointCollection.ReplacePointCollection(0, pointCollection.PointCount, pointCollection);
                                        //MessageBox.Show("before remove: " + pointCollection.PointCount);
                                        // Remove the point from the collection.
                                        //pointCollection.RemovePoints(i, 1);
                                        pointCollection.RemovePoints(vertexIndexToRemove, 1);
                                        //MessageBox.Show("after remove: " + pointCollection.PointCount);

                                        // Increment the total number of vertices removed
                                        numberOfVerticesRemovedFromPntCollection =
                                            numberOfVerticesRemovedFromPntCollection + 1;

                                        // since we are removing this current point, make sure we don't assign it as the previousPoint (in other words keep the active previous point for the next iterattion)
                                        updatePreviousPnt = false;

                                        // reset the point collection, now that the point has been removed
                                        //pointCollection.ReplacePointCollection(i,i- pointCollection.PointCount,pointCollection);

                                        // Replace the features shape with the newly modified point collection.
                                        //clsGlobals.arcFeatureToEditSpatial.Shape = pointCollection as IGeometry;
                                        //clsGlobals.arcFeatureToEditSpatial.Store();
                                    }

                                    // release the feature cursor
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursorCurr);
                                }
                            }


                            // Set this current point to the next point, so next time through the iteration we can check the distance between them.
                            if (updatePreviousPnt)
                            {
                                previousPoint = null;
                                previousPoint = currPoint;
                            }

                            //MessageBox.Show("total times though the loop: " + i);
                        }


                        //// Remove the ID'd verticies from this segment
                        //foreach (var index in listOfIndexesToRemove)
                        //{
                        //    // Remove the point from the collection.
                        //    pointCollection.RemovePoints(index, 1);
                        //}

                        // Replace the features shape with the newly modified point collection.
                        clsGlobals.arcFeatureToEditSpatial.Shape = pointCollection as IGeometry;
                        clsGlobals.arcFeatureToEditSpatial.Store();
                        clsGlobals.arcEditor.StopOperation("RemovedDuplicateVertices");
                    }

                    //close the stream writer
                    streamWriter.Close();

                    MessageBox.Show(
                        "Done updating " + arcSelectionSet.Count +
                        " features on the REMOVE_DUP_VERTS Layer, removing non-coincident vertices that were within 1 meter of eachother.  Don't forget to save edits if you want to retain the changes.",
                        "Done!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "Push Utrans Roads to SGID!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                clsGlobals.arcEditor.StopOperation("RemovedDuplicateVertices");
            }
        }