hira34

Restart IFeatureCursor

Discussion created by hira34 on Jul 29, 2011
Public Sub MergParcels()

pWorkspaceFactory = New ShapefileWorkspaceFactory
pFWS = pWorkspaceFactory.OpenFromFile("D:\Oman temp", 0)

Dim span As IFeatureClass = pFWS.OpenFeatureClass("FO_Duct_Merge")
MsgBox("open span")
Dim napPoint As IFeatureClass = pFWS.OpenFeatureClass("FO_Chamber")
MsgBox("open structures")
Dim parcels As IFeatureClass = pFWS.OpenFeatureClass("Parcel")
MsgBox("open Parcel")
Dim napPoly As IFeatureClass = pFWS.OpenFeatureClass("Nap_Polygon")
MsgBox("Open block_poly")


Dim pStructure As IFeature
Dim lSpan As IFeature
Dim cStructure As IFeature
Dim pPoly As IFeature
Dim newFeat As IFeature

Dim pStructureFilter As ISpatialFilter = New SpatialFilter
Dim lspanFilter As ISpatialFilter = New SpatialFilter

Dim spanCursor As IFeatureCursor
Dim lSpanCursor As IFeatureCursor
Dim polyCursor As IFeatureCursor

Dim structureGeom As IGeometry
Dim spanGeom As IGeometry

Dim chamberNo As Integer
Dim i As Integer = 0
Dim getLength As Double

Dim pTopoOp As ITopologicalOperator
Dim geometryBag As IGeometry = New GeometryBagClass()
Dim geometryCollection As IGeometryCollection = CType(geometryBag, IGeometryCollection)


pStructure = napPoint.GetFeature(i)
pTopoOp = pStructure.Shape
structureGeom = pTopoOp.Buffer(8)
pStructureFilter.Geometry = structureGeom
pStructureFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
lSpanCursor = span.Search(pStructureFilter, Nothing)
lSpan = lSpanCursor.NextFeature


Do Until lSpan Is Nothing

spanGeom = lSpan.Shape
lspanFilter.Geometry = spanGeom
lspanFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
polyCursor = parcels.Search(lspanFilter, Nothing)
pPoly = polyCursor.NextFeature

Do Until pPoly Is Nothing
MsgBox("hira")
Dim missing1 As Object = System.Type.Missing
geometryCollection.AddGeometry(pPoly.Shape, missing1, missing1)
pPoly = polyCursor.NextFeature
Loop

getLength = lSpan.Value(lSpan.Fields.FindField("SHAPE_LEN"))
If getLength < 100 Then
lspanFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
structureCursor = napPoint.Search(lspanFilter, Nothing)
cStructure = structureCursor.NextFeature
chamberNo = cStructure.Value(cStructure.Fields.FindField("FID"))
If chamberNo <> i Then

i = chamberNo

pStructure = napPoint.GetFeature(i)
pTopoOp = pStructure.Shape
structureGeom = pTopoOp.Buffer(8)
pStructureFilter.Geometry = structureGeom
pStructureFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
spanCursor = span.Search(pStructureFilter, Nothing)
lSpan = spanCursor.NextFeature

Do Until lSpan Is Nothing
spanGeom = lSpan.Shape
lspanFilter.Geometry = spanGeom
lspanFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
polyCursor = parcels.Search(lspanFilter, Nothing)
pPoly = polyCursor.NextFeature

Do Until pPoly Is Nothing
Dim missing2 As Object = System.Type.Missing
geometryCollection.AddGeometry(pPoly.Shape, missing2, missing2)
pPoly = polyCursor.NextFeature
Loop

lSpan = spanCursor.NextFeature
Loop

End If
End If


lSpan = spanCursor.NextFeature
Loop


pTopoOp = New PolygonClass()
pTopoOp.ConstructUnion(geometryBag)
Dim poly As IPolygon2
poly = CType(pTopoOp, IPolygon)
newFeat = napPoly.CreateFeature
newFeat.Shape = poly
newFeat.Value(1) = newFeat.Shape
newFeat.Value(3) = i
newFeat.Store()

End Sub

actullay i want to merge parcels that are intersecting line features(span) of 2 different Point features (napPoint). but it skips some parcels from the merged one.if their is some problem in my logic , kindly help me in that regard also.

Outcomes