Total's Mapasic Teaching - Output Specific Information to a text file and how to calculate another endpoint

xiaoxiao2021-03-05  19

This is a piece of code I wrote by MapBasic software, I hope to help everyone. This code is not picked in mapinfo, but I know two endpoints, I believe everyone knows what to do :)

'********************************************************** *********************************** 'Program Name: Export Tems .cel File'Author: liu hui'date: 18/03/2004 'Description: The Sub Program Will Export Some Specify Information INTO' A TEXT FILE. '' '******************************* ******************************************************

INCLUDE "mapbasic.def"

Global X2, Y2 As Floatglobal X1, Y1 As Floatglobal Angle, Length As Floator Sub GetendPointDeclare Sub Main

'The Sub Program Will Create a Tool Bar in MapInfo WinDow'Sub CreateToolbar

'End Sub

Sub main

DIM I AS INTEGERDIM Sec AS STRINGDIM S AS STRINGDIM NUMTBLS AS INTEGERDIM FNEI, FFRE AS Logicaldim Flagnei, Flagfre As Logical

Numtbls = NumTables () Fnei = falseffre = false

'Check WHETHER NOT The "neighbor" Table and "Frequency" Table EXIST

For i = 1 to NumTblsif TableInfo (i, tab_info_name) = "frequency" Then 'ffre = true if "frequency" Table Existffre = trueEnd IF

If TableInfo (i, tab_info_name) = "neighbor" the 'fnei = true if "neighbor" Table ExistFnei = trueEnd IF

NEXT

IF not fnei tenflagnei = ask ("Neighbor Table Not Exist, You Want to Export Any Way?", "Yes", "NO") if NOT FLAGNEI THENEXIT SUBEND IFEND IF

IF not ffre damfre = ask ("Frequency Table Not Exist, You Want to Export Any Way?", "Yes", "NO") if NOT FLAGFRE THENEXIT SUBEND IFEND IF

i = 1Fetch REC 20 from setuplength = setup.pathorvalue

Open file "C: /Temp.cel" for Output AS # 1 'Out this here You can also specify a path as an output length = (Length / 100) / 2Fetch Rec 1 from frequencydo while not eot (LENGTH / 100) / 2FETCH REC 1 from frequencydo While Not Eot ( frequency) fetch rec i from frequencyx1 = frequency.Easting 'reading accuracy y1 = frequency.Northing' reads latitude sec = frequency.sectorid 'specific entry angle = frequency.antalign' direction angle call getendpoint 'call another function calculated line getEndpoint One Endpoint S = Sec & "" & Str $ (x2) & "& str $ (y2) Print # 1, s' Output Data to File i = i 1LoopClose File # 1END SUB

Sub getndpoint 'This is a very useful function that can be determined by another endpoint that appears according to a point and an angle value, and can correct the error DIM DELTA_X, DELTA_Y, DELTA_Y, MIDPOINT_Y, Error_Margin as Floatdim Item Item ITAS SMALLINT.

orthoterations = 5 'This is a length, indicating 5 error corrections, you can also change this value, which will be more accurate. DIM ICOUNTER AS Smallint if Angle <= 90 Then 'here is a correction direction, want to know his role? Delete this IF will try to know Angle = 90 - Angle elseif Angle <= 450 Then Angle = 450 - Angle

End if if Length = 0 THEN X2 = x1 y2 = Y1 EXIT SUB end ifdelta_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_xicounter = 1 do while iCounter <= ABS (Itemions) 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

转载请注明原文地址:https://www.9cbs.com/read-39359.html

New Post(0)