MGRSToPoint() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Converts a string representing an MGRS (Military Grid Reference System) coordinate into a point object in the current MapBasic coordinate system. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

MGRSToPoint( string )

string is a string expression representing an MGRS coordinate.

The default Longitude/Latitude coordinate system is used as the initial selection.

Return Value

Object

Description

The returned point will be in the current MapBasic coordinate system, which by default is Long/Lat (no datum). For the most accurate results when saving the resulting points to a table, set the MapBasic coordinate system to match the destination table's coordinate system before calling MGRSToPoint(). This will prevent MapInfo Pro from doing an intermediate conversion to the datumless Long/Lat coordinate system, which can cause a significant loss of precision.

Example

Example 1:

dim obj1 as Object 
dim s_mgrs As String 
dim obj2 as Object 
obj1 = CreatePoint(-74.669, 43.263)
s_mgrs = PointToMGRS$(obj1)
obj2 = MGRSToPoint(s_mgrs)

Example 2:

Open Table "C:\Temp\MyTable.TAB" as MGRSfile
' When using the PointToMGRS$() or MGRSToPoint() functions,
' it is very important to make sure that the current MapBasic 
' coordsys matches the coordsys of the table where the
' point object is being stored.
'Set the MapBasic coordsys to that of the table used
Set CoordSys Table MGRSfile
'Update a Character column (for example COL2) with MGRS strings from
'a table of points
Update MGRSfile
	Set Col2 = PointToMGRS$(obj)
'Update two float columns (Col3 & Col4) with
'CentroidX & CentroidY information 
'from a character column (Col2) that contains MGRS strings.
Update MGRSfile
	Set Col3 = CentroidX(MGRSToPoint(Col2))
Update mgrstestfile ' MGRSfile
	Set Col4 = CentroidY(MGRSToPoint(Col2))
Commit Table MGRSfile
Close Table MGRSfile

See Also:

PointToMGRS$() function