Home arrow GIS Data & Resources arrow Scripts and Code arrow Visual Basic / VBA arrow VBA: Check for Non-Linear Geometry
VBA: Check for Non-Linear Geometry PDF Print E-mail

Written by Bert Granberg,

The ArcGIS Geodatabase model allows for the storage of true curves in the form of Bezier, Circular, and Eliptical Arcs. Some software (including the spatial query in ESRI's own ArcGIS Server 9.2 doesn't work well with these departures from the basic linear features described as a list of x,y coordinate pair vertices.

This script can be used to detect non-linear segments in a geodatabase feature class. Object ID's are output to a text file. Run it from ArcMap, it will work on the first layer (position 0 in the TOC).

The fastest way to bulk convert these curves to line-based segments is to export to a shapefile, although it is possible to operate on the geometry programatically so you can avoid exporting and reloading your data.

Public Sub findNonLinearSegments()


    Open "c:/temp/nonlineargeogeometry.txt" For Output As #1
    
    Dim pMxDoc As IMxDocument
    Dim pMap As IMap
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap
    
    Dim pSrcLayer As IFeatureLayer
    Dim pSrcFeatureClass As IFeatureClass
    Dim pSrcFeatureCursor As IFeatureCursor
    Dim pSrcFeature As IFeature
    Dim pPolygon As IPolygon
    Dim pSegCol As ISegmentCollection
    Dim pArea As IArea
    Dim pQF As IQueryFilter

    Set pSrcLayer = pMap.Layer(0)  '(Source Layer is first layer in TOC)
    Set pSrcFeatureClass = pSrcLayer.FeatureClass
    
    Set pQF = New QueryFilter
    pQF.WhereClause = ""
   
    Set pSrcFeatureCursor = pSrcLayer.Search(pQF, True)
    Set pSrcFeature = pSrcFeatureCursor.NextFeature
    
      'iterate through quad features (which are all polygons with 5 points)
    Do Until pSrcFeature Is Nothing
      

      Set pPolygon = pSrcFeature.Shape
      Set pSegCol = pPolygon
      Dim pEnumSegs As IEnumSegment
      Dim pSeg As ISegment
      Dim partindex As Long
      Dim segindex As Long

      Set pEnumSegs = pSegCol.EnumSegments
      pEnumSegs.Next pSeg, partindex, segindex
      Do Until pSeg Is Nothing
        If TypeOf pSeg Is IBezierCurve Or TypeOf pSeg Is IEllipticArc Or TypeOf pSeg Is ICircularArc Then
            Print #1, pSrcFeature.OID & " " & pSrcLayer.Name
            Exit Do
        Else
            Debug.Print pSrcFeature.OID
        End If
        
        'Set pSeg = pEnumSegs.Next
        pEnumSegs.Next pSeg, partindex, segindex
      Loop
      Set pSrcFeature = pSrcFeatureCursor.NextFeature
    Loop
    Close #1
End Sub

Users' Comments  
 

Display 1 of 1 comments

1. Tue, 03-10-2009 at 02:19 PM

thanks bert. always makin' it happen!

Display 1 of 1 comments

Add your comment

10, Mar. 2009
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for