How To: Identify topology errors containing true curves
When using ArcGIS 9.3 Service Pack 1, validating a geodatabase topology may incorrectly modify the shape of true curves in the data. This issue has been resolved with the ArcGIS 9.3 Service Pack 1 (Desktop, Engine, Server) Topology Validation Patch and an updated ArcGIS 9.3 Service Pack 1 (released on November 24, 2008).
This issue may be experienced if the following four conditions are met:
- ArcGIS 9.3 with Service Pack 1 (downloaded prior to November 24, 2008) is installed.
- There are polygon feature classes containing true curves that participate in a geodatabase topology. Topologies without true curves are not affected.
- The true curves are coincident or overlap with other true curves.
- The topology has been validated on ArcGIS 9.3 with Service Pack 1 (downloaded prior to November 24, 2008). Other operations that create or modify true curves are not affected.
If this issue has been experienced, Esri recommends that a backup of data is retrieved, if available. Certain topology rules, such as those to find overlapping areas or areas where boundaries should be covered by other boundaries, may allow the incorrectly modified features to be identified and corrected with topology error fixes. Manual edits can also be performed to re-position the curves.
The following procedures provide code to determine if: 1) the polygon feature classes in the topology have true curves, and 2) there are topology errors containing true curves, which may indicate that the curves were incorrectly altered during the validate process.
- Start ArcMap and add the geodatabase topology and the feature classes participating in it.
- Start editing and add the Topology toolbar to ArcMap.
- Ensure the geodatabase topology is the active topology on the Topology toolbar.
- Open the Visual Basic Editor.
- In ArcMap, select Tools > Macros > Visual Basic Editor.
- In the Project Explorer window, expand Project and click ArcMap Objects > ThisDocument, right-click, and click View Code.
- Click the show me link below and copy and paste the following code into the code module.
Sub ReportCurvedSegmentCount() On Error GoTo EH Dim pTopology As ITopology Dim editor As IEditor Dim id As New UID Dim topologyExtension As ITopologyExtension Dim teID As New UID id = "esriEditor.editor" Set editor = Application.FindExtensionByCLSID(id) teID = "esriEditorExt.TopologyExtension" Set topologyExtension = Application.FindExtensionByCLSID(teID) If topologyExtension.CurrentTopology Is Nothing Then Exit Sub If TypeOf topologyExtension Is IMapTopology Then MsgBox "You must select a geodatabase topology" Exit Sub End If Dim featureClassContainer As IFeatureClassContainer Set featureClassContainer = topologyExtension.CurrentTopology Dim i As Integer For i = 0 To featureClassContainer.ClassCount - 1 Dim curveCount As Long curveCount = 0 Dim featureClass As IFeatureClass Set featureClass = featureClassContainer.Class(i) If featureClass.ShapeType = esriGeometryPolygon Then Dim featCursor As IFeatureCursor Set featCursor = featureClass.Search(Nothing, True) Dim feature As IFeature Set feature = featCursor.NextFeature Do While Not feature Is Nothing Dim segColl As ISegmentCollection Set segColl = feature.ShapeCopy Dim hasCurves As Boolean hasCurves = False segColl.HasNonLinearSegments hasCurves If hasCurves = True Then curveCount = curveCount + 1 End If Set feature = featCursor.NextFeature Loop Debug.Print "Feature class: " & featureClass.AliasName & ", CurveCount: " & curveCount End If Next i MsgBox "Analysis complete", vbOKOnly, "Report Curved Segment Count" Exit Sub EH: MsgBox "Unknown error", vbExclamation, "Report Curved Segment Count" End Sub
- Run the code from inside the Visual Basic Editor by clicking the Run Sub/User Form button on the Standard toolbar or the Run menu.
- A report of the polygon feature classes in the topology and the number of true curves in them appears in the Immediate window in the Visual Basic Editor. To open this window, click View and click Immediate Window. Close the Visual Basic Editor and ArcMap when done.
If the results indicate that there are true curves in the feature classes in the topology, perform the next steps to determine possible locations where curves may have been altered during validation. The following procedures require that topology rules are in place to find overlapping areas or areas where boundaries should be covered by other boundaries. Code is provided to help identify locations where a true curve is part of a topology error.
- If using a personal or file geodatabase, skip this step.
If using data from an ArcSDE geodatabase, copy data into a file geodatabase and perform the following steps using a file geodatabase. Once the edits have been completed, if any are needed, the data can be reintroduced into the ArcSDE geodatabase.
- If the topology does not currently include rules such as Must Not Overlap, Must Be Covered By Feature Class Of, Boundary Must Be Covered By, and so on, add them to the topology in ArcCatalog.
- Start editing and create a line or polygon feature that spans the dataset’s extent. For example, create a line feature starting just beyond the lower left corner of the data, and ending just beyond the upper right corner of the data.
If working with a file geodatabase feature class and the extent of the data is very large, this feature may exceed the maximum number of spatial index grids. If an error occurs, see the following help topic to learn how to change the grid size: Setting spatial indexes.
- Delete the newly created feature. This creates a topology dirty area over the entire extent.
- Validate the topology.
- Open the Topology Error Inspector window.
- Open the Visual Basic Editor, and use the procedures above to copy and paste the following code into the code module. Run the code.
Public Sub TopoErrorWithCurve() 'Display topology errors that contain non linear features Dim pTopoUiD As New esriSystem.UID Dim pTopoExt As ITopologyExtension Dim pTopology As ITopology Dim pGeoDS As IGeoDataset Dim pErrorContainer As IErrorFeatureContainer Dim pErrorFeat As IEnumTopologyErrorFeature Dim pTopoErrFeature As ITopologyErrorFeature Dim bNonLinear As Boolean Dim pFeature As IFeature Dim pSc As ISegmentCollection 'get the topo extension pTopoUiD.Value = "esriEditorExt.TopologyExtension" Set pTopoExt = Application.FindExtensionByCLSID(pTopoUiD) 'get the topology Set pTopology = pTopoExt.CurrentTopology Set pGeoDS = pTopology 'get the errors Set pErrorContainer = pTopology Set pErrorFeat = pErrorContainer.ErrorFeaturesByRuleType(pGeoDS.SpatialReference, esriTopologyRuleType.esriTRTAny, Nothing, True, False) 'clear active errors pTopoExt.ClearActiveErrors esriTEEventHint.esriTENone pTopoExt.DelayEvents True bNonLinear = False Set pTopoErrFeature = pErrorFeat.Next 'loop through each error feature Do While Not pTopoErrFeature Is Nothing Set pFeature = pTopoErrFeature If (pFeature.Shape.GeometryType = esriGeometryType.esriGeometryPolyline) Or (pFeature.Shape.GeometryType = esriGeometryType.esriGeometryPolygon) Then Set pSc = pFeature.ShapeCopy pSc.HasNonLinearSegments bNonLinear If bNonLinear Then 'add the error to the inspector pTopoExt.AddActiveError pTopoErrFeature, esriTEEventHint.esriTENone End If End If Set pTopoErrFeature = pErrorFeat.Next Loop pTopoExt.TopologySelectionChanged pTopoExt.DelayEvents False End Sub
- Look at the errors in the Topology Error Inspector. The ones listed should be features that violate the topology rules and have true curves in them.
- Use the ArcMap editing tools, or the topology fixes, to reshape any affected curves. See the following help topics for some potential methods of updating the data:
- Navigate to each error by right-clicking and zooming to it or by using the available keyboard shortcuts.
- Once the fixes are made, re-validate that extent, rerun the code (if required), and move to the next error until the edits are complete.