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 ...
随机推荐
- PHP:第五章——字符串的概念
<?php header("Content-Type:text/html;charset=utf-8"); //字符串概念: //1.单引号.//里面的变量不会被解释 //例 ...
- FireFox和IE下使用Date来构造新Date对象的BUG
正常方式 我们都知道可以使用new Date()来创建一个Date对象. new Date();//Date {Mon Jun 15 2015 15:53:16 GMT+0800} 也可以用new D ...
- Zabbix(Windows)
Windows环境下只能装客户端, 而不能装服务端; zabbix官网 https://www.zabbix.com/ 下载并解压到本地 修改配置文件: # Hostname=Hostname=DES ...
- 使用catch做单元测试简介
开始使用catch呢! catch的好处是,它只有一个头文件, 坏处是,它需要C++11,不过不是很坏. catch有两种测试用例的书写方式: Normal unsigned int Factoria ...
- C#中系统时间和UNIX时间戳互相转换
在项目开发过程中,有时会遇到不同程序之间相互调用数据,数据中不免会包含时间,比如ASP.NET调用PHP,牵扯到时间就要做一下处理,PHP程序中一般存取的都是UNIX时间,不像ASP.NET存储的是年 ...
- opencrud graphql 数据操作指南
opencrud 是社区团队提出,同时prisma框架就是按照这个标准设计的,里面包含了对于graphql 数据 操作的最佳实践,目前还在完善中,但是设计以及指南覆盖的功能还是比较全的,如果用过 pr ...
- 利用OCR文字识别+百度算法搜索,玩转冲顶大会、百万英雄、芝士超人等答题赢奖金游戏
[先上一张效果图]: 一.原理: 其实原理很简单: 1.手机投屏到电脑: 2.截取投屏画面的题目部分,进行识别,得到题目和三个答案: 3.将答案按照一定的算法,进行搜索,得出推荐答案: 4.添加了一些 ...
- Linux配置Nginx+Tomcat负载均衡
cd /usr/local/tomcat1/webapps/ROOT/ tar -zxvf nginx-1.14.2.tar.gz -C /usr/local 一.Linux配置Nginx 一.下载N ...
- VS2010 C++环境下DLL和LIB文件的生成与调试 备忘
利用VS2010工具,调试DLL文件的方法现总结如下: 在一个解决方案中生成两个工程,假设MYDLL和MYDLG两个工程,前者是DLL工程,后者DLG调用前边的DLL工程.设置如下: 目录如下:图,本 ...
- EF-CodeFirst系列100
.学习资料地址: CodeFirst:https://msdn.microsoft.com/zh-cn/data/jj193542 一.CodeFirst迁移(Migration) .工具--> ...