关于shape的线状文件生成问题!会的人救救我啊!

Private Sub Command4_Click()
Dim gds As MapObjects2.GeoDataset
Dim sName As String
Dim Desc As New TableDesc
Dim dc As New DataConnection
Dim Lyr As New MapObjects2.MapLayer
Dim resc As MapObjects2.Recordset
Dim rst1 As ADODB.Recordset
Dim i As Integer
Dim Cnn2 As ADODB.Connection
Dim P1 As MapObjects2.Point
Dim str1 As String
Dim X2 As Single, Y2 As Single
Dim X1 As Single, Y1 As Single

Set Cnn2 = New ADODB.Connection
str1 = "Provider=MicroSoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "/fuzhou1.mdb"
Cnn2.ConnectionString = str1
Cnn2.Open

Set rst1 = New ADODB.Recordset
rst1.Open "select * from office", Cnn2, adOpenStatic, adLockReadOnly

With CommonDialog1

.Filter = "ESRI  Shapefiles(*.shp)|*.shp"
.DefaultExt = ".shp"
.ShowSave
   
If Len(.FileName) = 0 Then Exit Sub
dc.Database = CurDir
If Not dc.Connect Then Exit Sub

sName = Left(.FileTitle, Len(.FileTitle) - 4)
End With

With Desc
.FieldCount = 2

.FieldName(0) = "Name"
.FieldName(1) = "id"


.FieldType(0) = moString
.FieldType(1) = moLong


.FieldLength(0) = 16
.FieldPrecision(1) = 15

End With


Set gds = dc.AddGeoDataset(sName, moPoint, Desc)
Set Lyr.GeoDataset = gds

For i = 1 To rst1.RecordCount
X1 = Format(Form2.Map1.FromMapDistance(rst1!x), "#.00")
Y1 = Format(Form2.Map1.FromMapDistance(rst1!y ), "#.00")
Set P1 = Form2.Map1.ToMapPoint(X1, Y1)
With Lyr.Records
.AddNew
.Fields("Shape").Value = P1
.Fields("Name").Value = rst1!name
.Fields("id").Value = rst1!id
.Update
End With
rst1.MoveNext
Next
Lyr.Symbol.Color = moMaroon

MsgBox "文件已生成"
Exit Sub
End Sub
这可以生成shape的点状文件,不过如果要生成线状文件要怎么改动程序呢?有没有人知道的可以帮我解决下啊,不甚感激!
数据库中的表(点:x(经度值)、y(纬度值)、id)
线:id    pid    x   y   recordno
     1     0               1
     1     1               2
     1     2               3
     1     3               4
     2     0               5
     2     1               6
     2     2               7
    .........
这是数据库表中的数据 

会的赶紧帮我一把啊!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值