I'm working on a MapBasic code and I have a problem. I wrote a code that calculates the length of the line that the user clicked on. my program calculates the length of the line. The program I write separately writes the start and end points of the line.
The first question I want to ask you is how can I show the number of decimal digits of the starting and ending coordinates of the line shown by the program as 3 digits? the returned values either show two digits or do not appear in decimal digits.
The second question I want to ask you is: the line length calculated with the program I wrote differs from the line length calculated with the calculator. what is the reason of this?
I converted the layer of the line object I draw in Mapinfo software to shape format using the Universal Translator tool.
I opened the table in ArcMap. the length of the same line in the table is very close to the length I calculate with my calculator. The result value I found in Mapinfo is not the same as the result I found in ArcMap.
I wrote another program using MapBasic. I created a dialog in the program. In my program, the user creates points in the layer with the X - Y coordinate values written in edittext. I created two points with the mapbasic program that I wrote. the program also writes the X - Y coordinates of the points on the screen after creating the point. when using the program I entered three digits of the decimal digits of the point coordinates. but the X - Y coordinates on the screen appear as two digits. I measure the distance between two points using the ruler in Mapinfo program. I also calculated the length using the X- Y coordinates that appear on the screen with the calculator. The length value that the ruler in Mapinfo finds is not the same as the length value I calculated.
When I tried the program I wrote in Mapinfo software, I set the projection of the layers I created as Türkish Coordinate Systems (3 degree k = 1 ITRF) Cenral Meridian 33.
Where am I doing wrong? Could you help me with this? thanks everyone
Picture of mapbasic program I wrote added this ask.
In order to calculate length of a line you don't need Pythagoras formula, simply use
ObjectLen(obje, "m")
In order to get desired number of digits have a look at function
Format$
. Examples from documentation:Before you create any objects or perform calculation you should set the coordinate system, for example
Note, you have
CoordSys
on several places, don't mix themSet Map ... CoordSys ...
which applies only for the map but not for objects in your code.Commit Table ... CoordSys...
which applies to saved table only.SessionInfo( SESSION_INFO_COORDSYS_CLAUSE )
String result that indicates a session's CoordSys clause.