Total的Mapbasic教学-输出特定信息到一个文本文件和如何算出线的另一个端点
来源:互联网 发布:mysql keylen 编辑:程序博客网 时间:2024/06/18 13:25
'*****************************************************************************
'Program Name: Export TEMS .Cel File
'Author: Liu Hui
'Date: 18/03/2004
'Description:The sub program will export some specifically information into
' a text file.
'
'
'*****************************************************************************
include "mapbasic.def"
Global x2,y2 as float
Global x1,y1 as float
Global angle,length as float
declare sub getendpoint
Declare sub main
'The sub program will create a tool bar in mapinfo window
'
'Sub CreateToolBar
'end sub
sub main
dim i as integer
dim sec as string
dim s as string
dim NumTbls as integer
dim fnei,ffre as logical
dim flagnei,flagfre as logical
NumTbls=Numtables()
fnei=false
ffre=false
'Check whether not the "neighbor" table and "Frequency" table exist
for i=1 to NumTbls
if tableinfo(i,TAB_INFO_NAME)="Frequency" then 'ffre=true if "frequency" table exist
ffre=true
end if
if tableinfo(i,Tab_info_name)="neighbor" then 'fnei=true if "Neighbor" table exist
fnei=true
end if
next
if not fnei then
flagnei=Ask("Neighbor table not exist,you want to export any way?","Yes","No")
if not flagnei then
exit sub
end if
end if
if not ffre then
flagfre=Ask("Frequency table not exist,you want to export any way?","Yes","No")
if not flagfre then
exit sub
end if
end if
i=1
fetch rec 20 from setup
length=setup.pathorvalue
Open File "c:/temp.cel" for output as #1 '输出这这里你也可以用mapbasic中的savefile函数指定一个路径作为输出
length=(length/100)/2
fetch rec 1 from frequency
do while not eot(frequency)
fetch rec i from frequency
x1=frequency.Easting '读取精度
y1=frequency.Northing '读取纬度
sec=frequency.sectorid '专用项
angle=frequency.antalign '方向角
call getendpoint '呼叫getendpoint函数算出线的另一端点
s=Sec & " " & Str$(X2) & " " & Str$(y2)
print #1,S '输出数据到文件
i=i+1
loop
close file #1
end sub
Sub GetEndpoint '这是一个很有用的函数,可以根据一个点和一个角度值算出现的另一个端点,并且可以修正不同方向上线长的误差
Dim delta_x, delta_y, midpoint_y, error_margin As Float
dim iterations as smallint
iterations=5 '这是一个长量,表示进行5次误差修正,你也可以改大这个值,这样会更精确一些。
Dim iCounter As Smallint
If angle <= 90 Then '在这里是修正方向角,想知道他的作用?删除这个if试试就知道了
angle = 90 - angle
ElseIf angle <= 450 Then
angle = 450 - angle
End If
If length = 0 Then
x2 = x1
y2 = y1
Exit Sub
End If
delta_y = (length * Sin( angle * DEG_2_RAD )) / 69.093
y2 = y1 + delta_y
midpoint_y = (y1 + y2) / 2
delta_x = (length * Cos(angle * DEG_2_RAD)) / (69.093 * Cos(midpoint_y * DEG_2_RAD))
x2 = x1 + delta_x
iCounter = 1
Do While iCounter <= Abs(iterations)
error_margin = (Distance(x1, y1, x2, y2, "mi" )- length) / length
delta_x = delta_x * (1 - error_margin)
delta_y = delta_y * (1 - error_margin)
x2 = x1 + delta_x
y2 = y1 + delta_y
iCounter = iCounter + 1
Loop
End Sub
- Total的Mapbasic教学-输出特定信息到一个文本文件和如何算出线的另一个端点
- Total 的mapbasic教学---定制工具按钮图标
- 编写一个C程序将一个文本的字符计算将字符个数输出到另一个文本文件(图)
- 把一个数据表的特定内容复制到另一个数据表
- struts2一个action返回到另一个action的特定result
- 如何从一个文件特定段落中(文本文件),读取相关的文件信息,并进行分段梳理
- 如何将一个文件里不包含某个字符的行输出到另一个文件?
- 如何将打印的log,输出到文本文件中
- 从一个缓冲到另一个缓冲的输出
- 读出一个文本文件,并在前面加上行号后,写入到另一个文件的简单例子
- 集合(2)把一个list集合中特定字段插入到另一个集合的特定字段中
- 输出照片中的GPS信息到文本文件,更新之前写的较复杂的程序
- 改变qDebug的输出到文本文件
- 如何将一个数据库的表复制到另一个数据库
- 编写一个在屏幕指定位置输出特定字符和特定颜色的子程序
- java中将一个文本文件复制到另一个文本文件中
- 如何求曲线上任意点到端点的距离
- 一个C#输出文本文件的问题
- 如果用PB实现将文件写入A盘
- 软件工程学习笔记(1)
- 新的生活:)
- 学外语的十条经验
- Total 的mapbasic教学---定制工具按钮图标
- Total的Mapbasic教学-输出特定信息到一个文本文件和如何算出线的另一个端点
- 学习类时想到的-原来还可以这样给INT类型赋值。
- Image wavelet histogram
- Spring Framework循序浅进(1)-原创
- java的“别名”以及clone机制
- 什么是安全认证(CA)?
- Start-up...
- 职场好人缘的26个细节
- 指定查询时使用的锁