我想问一下如何修复我的mapbasic代码以加快速度
实际上,我用mapbasic制作了一个程序正常工作,但运行时间很长,有时没有响应
我已经尝试修改代码但没有任何变化:(
这是我的代码
Sub ProsesBuffer
Create Table "Buffer2"
(Block_no Char(15),Remark Char(10),Type_Palm Char(10),Ha Decimal(6,2))
File "D:\Buffer2.TAB"
TYPE NATIVE Charset "WindowsLatin1"
Create Map For Buffer2 CoordSys Earth Projection 1, 104
Set Table Buffer2 FastEdit On Undo Off
Create Object As Buffer From sensus Width 5 Units "m" Type Spherical Resolution 100 Into Table Buffer2 Group by Rowid
Update Buffer2 Set Ha = Area(obj, "sq m")
Commit Table Buffer2
Create Index On Buffer2 (Block_no)
Add Map Layer Buffer2
Create Table "Check_Region"
(Block_no Char(15),Remark Char(10),Type_Palm Char(10),Ha Decimal(6,2))
File "D:\Check_Region.TAB"
TYPE NATIVE Charset "WindowsLatin1"
Create Map For Check_Region CoordSys Earth Projection 1, 104
Create Index On Check_Region (Block_no)
Add Map Layer Check_Region
Set Map Layer 1 Editable On
Set Table Buffer2 FastEdit On Undo Off
Objects Check From Buffer2 Into Table Check_Region Overlap Pen (1,2,0) Brush (2,16776960,0)
Commit Table Buffer2
Update Check_Region Set Ha = Area(obj, "sq m")
Commit Table Check_Region
Browse * From Check_Region
Set Map Layer 1 Editable Off Layer 2 Editable On
Add Column "Buffer2" (Ha) From Check_Region Set To sum(Ha) Where within
Browse * From Buffer2
'function stdev
Select count(*) "NL", sum(Ha) "Jlh_Ha",sum(Ha*Ha) "Sum_Sq", avg(Ha) "Mean" from Buffer2 into tbl_stdev
Browse * From tbl_stdev
dim numlines as integer
dim _sum_sq as float
dim _mean as float
dim _jlh_ha as float
fetch first from tbl_stdev
numlines=tbl_stdev.nl
_jlh_ha=tbl_stdev.jlh_ha
_sum_sq=tbl_stdev.sum_sq
_mean=tbl_stdev.mean
dim stdev as float
stdev= (_sum_sq - (_jlh_ha^2)/numlines)/(numlines-1)
print "stdev " + stdev
dim sd as float
sd=sqr(stdev)
dim stdev1 as float
dim stdev2 as float
dim stdev3 as float
stdev = _mean + 1 * sd
stdev2 = _mean + 2 * sd
stdev3 = _mean + 3 * sd
print "SD " + sd
print "STDEV1 " + stdev
print "STDEV2 " + stdev2
print "STDEV3 " + stdev3
Set Layer 1 Editable Off Layer 3 Editable On
select * from Buffer2 where Ha > stdev3 into Selection
browse * from Selection
Create Table "stdev3" (Block_no Char(15),Remark Char(10),Type_Palm Char(10),Ha Decimal(6,2)) file "D:\Buffer\stdev3.tab"
TYPE NATIVE Charset "WindowsLatin1"
Create Map For stdev3 CoordSys Earth Projection 1, 104
drop index stdev3 (Block_no)
Create Index On stdev3 (Block_no)
Add Map Layer stdev3
End Sub