Multipart polyline to single part lines
Breaking Up Polylines
http://forums.esri.com/Thread.asp?c=93&f=987&t=74554&mc=4#msgid197545
It appears as though IGeometryCollection is the way to go here, rather than ISegmentCollection. I noticed that the "ISegmentCollection" version created 905 line segments (from 15 polylines). ISegmentCollection created a line for every Single PAIR of vertices - 905 straight, two vertex lines.
There is no way I could have put this thing together at this point. Thanks for getting the ball rolling.
Hopefully, this can be useful to other users. Multipart lines can be a huge pain when you don't want them.
Sub ExplodePolyLines()
'
' From the original by Kirk Kuykendall.
'
Dim pUID As New UID
pUID.Value = "esricore.Editor"
Dim pEditor As IEditor
Set pEditor = Application.FindExtensionByCLSID(pUID)
If pEditor.EditState <> esriStateEditing Then
MsgBox "Make a shapefile editable."
Exit Sub
End If
Dim pEditlayers As IEditLayers
Set pEditlayers = pEditor
If pEditlayers.CurrentLayer.FeatureClass.ShapeType <> esriGeometryPolyline Then
Exit Sub
End If
Dim pFSel As IFeatureSelection
Set pFSel = pEditlayers.CurrentLayer
If pFSel.SelectionSet.Count = 0 Then
MsgBox "Select features to be broken up."
Exit Sub
End If
Dim pFCur As IFeatureCursor
pFSel.SelectionSet.Search Nothing, False, pFCur
pEditor.StartOperation
Dim pFeat As IFeature
Set pFeat = pFCur.NextFeature
Do Until pFeat Is Nothing
Dim pInGeomColl As IGeometryCollection
''' Dim pInSegColl As ISegmentCollection
''' Set pInSegColl = pFeat.ShapeCopy
Set pInGeomColl = pFeat.ShapeCopy
Application.StatusBar.Message(0) = "Exploding " & pFeat.OID
Dim l As Long
''' For l = 0 To pInSegColl.SegmentCount - 1
For l = 0 To pInGeomColl.GeometryCount - 1
''' Dim pOutSegColl As ISegmentCollection
''' Set pOutSegColl = New Polyline
Dim pOutGeomColl As IGeometryCollection
Set pOutGeomColl = New Polyline
''' pOutSegColl.AddSegment pInSegColl.Segment(l)
pOutGeomColl.AddGeometry pInGeomColl.Geometry(l)
Dim pOutFeat As IFeature
Set pOutFeat = pEditlayers.CurrentLayer.FeatureClass.CreateFeature
Dim k As Long
For k = 0 To pOutFeat.Fields.FieldCount - 1
If pOutFeat.Fields.Field(k).Editable Then
If pOutFeat.Fields.Field(k).Type <> esriFieldTypeGeometry Then
pOutFeat.Value(k) = pFeat.Value(k)
End If
End If
Next k
''' Set pOutFeat.Shape = pOutSegColl
Set pOutFeat.Shape = pOutGeomColl
pOutFeat.Store
Next l
pFeat.Delete
Set pFeat = pFCur.NextFeature
Loop
pEditor.StopOperation "Explode"
Dim pMxDoc As IMxDocument
Set pMxDoc = pEditor.Parent.Document
Dim pAV As IActiveView
Set pAV = pMxDoc.FocusMap
Dim lCacheID As Long
lCacheID = pAV.ScreenCacheID(esriViewGeoSelection, Nothing)
pAV.ScreenDisplay.Invalidate Nothing, True, lCacheID
MsgBox "Done"
End Sub
Multipart polyline to single part lines的更多相关文章
- Multipart to single part feature
Multipart to single part feature Explode Link: http://edndoc.esri.com/arcobjects/8.3/?URL=/arcobject ...
- [非官方]ArcGIS10.2 for Desktop扩展工具包——XTools Pro
XTools Pro 是一套为ArcGIS平台设计的矢量空间分析. 形状转换和表管理扩展工具,大大增强了 ArcGIS 的功能,使用该工具能够提高 ArcGIS 用户的效率和性能. XTools Pr ...
- leaflet地图库
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
- 关于arcgi s_api_for_flex的总结
1.flex 的简介 a) Flex是adobe开发的东西,主要特点就是开发一个swf格式的应用,flex可以做桌面的应用和web的应用,但本质差不多. b) Flex采用mxml的格式来进行应用的布 ...
- POJ 3845 Fractal(计算几何の旋转缩放)
Description Fractals are really cool mathematical objects. They have a lot of interesting properties ...
- POJ3041Asteroids(最小点覆盖+有点小抽象)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18289 Accepted: 9968 Descri ...
- Milking Cows
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...
- POJ 3041 Asteroids
最小点覆盖数==最大匹配数 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12678 Accepted: ...
- Asteroids(匈牙利算法入门)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16211 Accepted: 8819 Descri ...
随机推荐
- BZOJ3239 Discrete Logging
一道裸的BSGS题目(叫baby step, giant step) 从爱酱的blog里学来的,是一个很神的根号算法. 如果我们有hash的工具的话,就是O(sqrt(p))的,这里又用了一个map所 ...
- vim按下ctrl+s僵死
CTRL+S表示停止向终端停止输出 CTRL+Q恢复向终端输出流
- JDK配置 java跨平台性
jdk 虚拟机jre 依赖包javac 编译java 运行JAVA_HOME 一个存储jdk路径的自定义的变量,方便其他地方配置以后更改方便其他地方调用JAVA_HOME使用%JAVA_HOME%配置 ...
- 『转』谷歌发布Windows版Chrome App Launcher
据国外媒体报道,谷歌发布了Windows版Chrome App Launcher,Windows用户现在因此能够使用谷歌的许多网络应用,如Chrome浏览器.Gmail.Google Drive和Ch ...
- linux下部署tomcat服务器之安装jdk
如果一开始安装过jdk的可以卸载 rpm -qa | grep java rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x8 ...
- Alpha发布
作业链接[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2283] 视频展示 链接[https://v.youku.com/v_show/ ...
- OMAP4之DSP核(Tesla)软件开发学习(二)Linux内核驱动支持OMAP4 DSP核
注:必须是Linux/arm 3.0以上内核才支持RPMSG,在此使用的是.config - Linux/arm 3.0.31 Kernel Configuration.(soure code fro ...
- Nginx 防盗链设置
何谓'盗链' 此内容不在自己服务器上,而通过技术手段,绕过别人放广告有利益的最终页,直接在自己的有广告有利益的页面上向最终用户提供此内容. 常常是一些名不见经传的小网站来盗取一些有实力的大网站的地址( ...
- 《DSP using MATLAB》Problem 2.15
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- PHP连接不上MySQL解决方案总结
1. 获取当前 mysql.default_socket.mysqli.default_socket.pdo_mysql.default_socket 配置信息 建立一个 PHP 文件, 显示 php ...