pPolylineStart.SimplifyNetwork() pPolylineTest.SimplifyNetwork() pTopoOp = pPolylineTest pTopoOp.IsKnownSimple_2 =False pTopoOp.Simplify() pPolyline = pTopoOp.SymmetricalDifference(pPolylineStart)
Dim pNewFeature As ESRI.ArcGIS.Geodatabase.IFeature = Nothing Dim pNewPolyline As ESRI.ArcGIS.Geometry.IPolyline = Nothing Dim pOtherPolyline As ESRI.ArcGIS.Geometry.IPolyline = Nothing Dim pTopoOp As ESRI.ArcGIS.Geometry.ITopologicalOperator5 = Nothing Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature = Nothing ' Featureset contains two or more sector line ' features that have the same assignment and belong ' to the same perimeter polygon. Merge their shapes ' to create as single geometry from them. ' Get the feature metadata from the first feature. ' it will be used to populate metadata on the resulting ' feature. Since all the line features are associated ' with the same polygon, they should all have the ' same metadata. Dim pMetadata As FIMTExtensionNET.clsFIMTMetadataNET pMetadata = Nothing FeatureSet.Reset() pFeature = FeatureSet.Next Do While Not pFeature Is Nothing If pMetadata Is Nothing Then pMetadata = New FIMTExtensionNET.clsFIMTMetadataNET pMetadata.GetFeatureMetaData(pFeature) End If If pNewPolyline Is Nothing Then pNewPolyline = pFeature.ShapeCopy pTopoOp = CType(pNewPolyline, ESRI.ArcGIS.Geometry.ITopologicalOperator5) pTopoOp.IsKnownSimple_2 = False '051710 pTopoOp.Simplify() '051710 Else pOtherPolyline = pFeature.ShapeCopy 'Simplify the just obtained OtherPolyLine pTopoOp = CType(pOtherPolyline, ESRI.ArcGIS.Geometry.ITopologicalOperator5) '051710 pTopoOp.IsKnownSimple_2 = False pTopoOp.Simplify() 'Reset the pTopoOp to pNewPolyLine in prep for the union pTopoOp = CType(pNewPolyline, ESRI.ArcGIS.Geometry.ITopologicalOperator5) pNewPolyline = pTopoOp.Union(pOtherPolyline) 'Simplify the resulting New Line pTopoOp = CType(pNewPolyline, ESRI.ArcGIS.Geometry.ITopologicalOperator5) pTopoOp.IsKnownSimple_2 = False pTopoOp.Simplify() End If pFeature = FeatureSet.Next Loop
'Set these values at the start Dim azimuthField, distanceField As Long azimuthField = form.inputField distanceField = form.OutputField ' Get map object Dim mxd As IMxDocument Dim map As IMap mxd = CType(m_application.Document, IMxDocument) map = mxd.FocusMap 'Get feature classes, first is points, then borders Dim ptLayer As IFeatureLayer Dim borderLayer As IFeatureLayer Dim ptClass As IFeatureClass Dim borderClass As IFeatureClass ptLayer = form.InputLayer ptClass = ptLayer.FeatureClass borderLayer = form.BorderLayer borderClass = borderLayer.FeatureClass ' loop through each point feature Dim featCur As IFeatureCursor ' This is a search to ensure that only non-processed features are processed Dim filt As IQueryFilter = New QueryFilter() Dim f As IField = ptClass.Fields.Field(distanceField) filt.WhereClause = f.Name + " = 0" featCur = ptClass.Update(filt, True) Dim feat As IFeature feat = featCur.NextFeature() Dim pt As IPoint Dim azimuth, dist, i As Double ' This will store the azimuth direction Dim maxDist As Double Dim tempSegs As ISegmentCollection = New Polyline() Dim tempSegsGeog As IGeometry Dim tempFeat As IFeature Dim topo As ITopologicalOperator5 Dim prox As IProximityOperator Dim geomTemp As IGeometry maxDist = 100000000 Try While Not feat Is Nothing maxDist = 100000000 pt = feat.ShapeCopy azimuth = CDbl(feat.Value(azimuthField)) Dim tempLine As ILine ' This function creates the temporary line feature used to intersect tempLine = createTempLine(pt, CDbl(azimuth)) 'The line needs to be wrapped in a polyline to fit in the spatial filter If tempSegs.SegmentCount > 0 Then For i = 0 To tempSegs.SegmentCount - 1 tempSegs.RemoveSegments(i, 1, False) Next End If tempSegs.AddSegment(tempLine) tempSegsGeog = tempSegs tempSegsGeog.SpatialReference = feat.Shape.SpatialReference Dim spatial As ISpatialFilter = New SpatialFilter() spatial.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects spatial.Geometry = tempSegs ' A spatial query is used to get the intersetion points, I thought this is where the memeory leak was happening, but I don't think so anymore (after examining the call stack Dim tempFeatCur As IFeatureCursor = borderClass.Search(spatial, True) tempFeat = tempFeatCur.NextFeature() While Not tempFeat Is Nothing topo = tempFeat.Shape topo.IsKnownSimple_2 = False topo.Simplify() ' attempt to fix intermitent error following http://forums.arcgis.com/threads/1992-ITopological-Operator-Intermittent-COMException-on-Union 'This is where the error is occuring, at least it is for the first time geomTemp = topo.Intersect(tempSegsGeog, esriGeometryDimension.esriGeometry0Dimension) prox = geomTemp dist = prox.ReturnDistance(pt) If dist < maxDist Then maxDist = dist End If tempFeat = tempFeatCur.NextFeature() End While System.Runtime.InteropServices.Marshal.ReleaseComObject(tempFeatCur) System.Runtime.InteropServices.Marshal.ReleaseComObject(tempLine) feat.Value(distanceField) = maxDist featCur.UpdateFeature(feat) feat = featCur.NextFeature() End While Catch ex As System.Runtime.InteropServices.COMException System.Windows.Forms.MessageBox.Show(ex.Message) End Try System.Windows.Forms.MessageBox.Show("Finished Calculating Distances") End If
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.