MapX中access表图形化为mapinfo表的两种途径

http://edu.zdor.cn/tools/0804/201265.htm

 

MapX中access表图形化为mapinfo表的两种途径 【来自】中国GIS资讯网 作者:hitler 时间:08-04-24 17:59 access表-->MI表有两种途径: 1.bindlayerXY方式绑定。指定bindlayer.filespec就可以创建永久表,不指定则为临时表。 Private Sub Command4_Click() '只能创建一个字段,GeoName,来源于City字段。当City字段不能唯一是,state字段用于限定。 '不能创建索引 Dim BindlayerObject As New mapxlib.BindLayer Dim db As DAO.Database Dim rs As DAO.Recordset Dim ds As mapxlib.Dataset Set db = DBEngine.WorkSpaces(0).Opendatabase("C:/Program Files/MapInfo/MapX 4.0/Data/Mapstats.mdb") Set rs = db.OpenRecordset("US_Cust") BindlayerObject.LayerName = "新图层名" BindlayerObject.Filespec = App.Path + "/mytab.tab" '若不指定,则为临时表 BindlayerObject.RefColumn1 = "X" BindlayerObject.RefColumn2 = "Y" BindlayerObject.LayerType = miBindLayerTypeXY Set ds = Map1.Datasets.Add(miDataSetDAO, rs, "数据集名", "City", "State", BindlayerObject) End Sub 2.layerInfo新建表 layers.add lyrinfo创建好一个有完备字段的空表 ds.rowvalues, lyr.addfeature ftr,rvs填入图元和属性 Private Sub Command1_Click() '可以创建多个字段 'mapx5中可以创建索引,mapx4中不可以 Dim rs As DAO.Recordset Dim db As DAO.Database Dim flds As New MapXLib.Fields Dim lyrNew As MapXLib.Layer Dim ptNew As New MapXLib.Point Dim ftrNew As MapXLib.Feature Dim ff As MapXLib.FeatureFactory Dim li As New MapXLib.LayerInfo Dim rvs As New MapXLib.Rowvalues Dim ds As MapXLib.Dataset Set db = DBEngine.OpenDatabase("C:/Program Files/MapInfo/MapX 4.0/data/mapstats.mdb") Set rs = db.OpenRecordset("US_Cust") Set ff = Map1.FeatureFactory flds.AddStringField "Company", 50 ,true 'mapx5中可以创建索引, 'flds.AddStringField "Company", 50 'mapx4中不可以创建索引, flds.AddStringField "City", 50 flds.AddStringField "State", 2 flds.AddNumericField "Order_Amt", 12, 2 li.Type = miLayerInfoTypeNewTable li.AddParameter "FileSpec", App.Path & "/custtab.tab" li.AddParameter "Name", "mycustomers" li.AddParameter "Fields", flds Map1.Layers.Add li, 1 '到此为止,已经用access表建好mapinfo表,也设置好了字段,但是没有图元在上面,也没有记录。 '下面从access表中x,y创建点图元,同时把其属性数据也添加进去 '-------------------------------------------------------------------- Set lyrNew = Map1.Layers(1) Set ds = Map1.Datasets.Add(miDataSetLayer, lyrNew) Set rvs = ds.Rowvalues(0) rs.MoveFirst Do While Not rs.EOF rvs.Item("Company").value = rs.Fields("Company") 'rvs.Item("Company")可写为rvs("Company") rvs.Item("City").value = rs.Fields("City") rvs.Item("State").value = rs.Fields("State") rvs.Item("Order_Amt").value = rs.Fields("Order_Amt") ptNew.Set rs.Fields("X"), rs.Fields("Y") Set ftrNew = ff.CreateSymbol(ptNew) Set ftrNew = lyrNew.AddFeature(ftrNew, rvs) ' 图元+属性,即feature+Rowvalues 'Set ftrNew = lyrNew.AddFeature(ftrNew) 'ftrNew.Update True, rvs rs.MoveNext Loop Set rs = Nothing Set db = Nothing End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值