Purpose
Returns the x-coordinate of a specific node in a region or polyline object. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
ObjectNodeX( object, polygon_num, node_num )
object is an Object expression.
polygon_num is a positive integer value indicating which polygon or section to query. It is ignored for Multipoint objects (it used for regions and polylines).
node_num is a positive integer value indicating which node to read.
Return Value
Float
Description
The ObjectNodeX() function returns the x-value of a specific node from a region or polyline object. The corresponding ObjectNodeY() function returns the y-coordinate value.
The polygon_num parameter must have a value of one or more. This specifies which polygon (if querying a region) or which section (if querying a polyline) should be queried. Call the ObjectInfo() function to determine the number of polygons or sections in an object. The ObjectNodeX() function supports Multipoint objects and returns the x-coordinate of a specific node in a Multipoint object.
The node_num parameter must have a value of one or more; this tells MapBasic which of the object's nodes should be queried. You can use the ObjectInfo() function to determine the number of nodes in an object. The ObjectNodeX() function returns the value in the coordinate system currently in use by MapBasic; by default, MapBasic uses a Longitude/Latitude coordinate system. See Set CoordSys statement for more information about coordinate systems.
Example
The following example queries the first graphic object in the table Routes. If the first object is a polyline, the program queries the x- and y-coordinates of the first node in the polyline, then creates a new Point object at the location of the polyline's starting node.
Dim i_obj_type As SmallInt, x, y As Float, new_pnt As Object
Open Table "routes"
Fetch First From routes
' at this point, the expression:
' routes.obj
' represents the graphical object that's attached
' to the first record of the routes table.
i_obj_type = ObjectInfo(routes.obj, OBJ_INFO_TYPE)
If i_obj_type = OBJ_PLINE Then
' ... then the object is a polyline...
x = ObjectNodeX(routes.obj, 1, 1) ' read longitude
y = ObjectNodeY(routes.obj, 1, 1) ' read latitude
Create Point Into Variable new_pnt (x, y)
Insert Into routes (obj) Values (new_pnt)
End If
See Also:
Alter Object statement, ObjectGeography() function, ObjectInfo() function, ObjectNodeY() function, Set CoordSys statement