CreatePoint() 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

Returns an Object value representing a point. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

CreatePoint( x, y )

x is a float value, representing an x-position (for example, Longitude).

y is a float value, representing a y-position (for example, Latitude).

Return Value

Object

Description

The CreatePoint() function returns an Object value representing a point.

The x and y parameters should use whatever coordinate system MapBasic is currently using. By default, MapBasic uses a Longitude/Latitude coordinate system, although the Set CoordSys statement can re-configure MapBasic to use a different coordinate system. Note that MapBasic's coordinate system is independent of the coordinate system of any Map window.

The point object will use whatever Symbol style is currently selected. To create a point object with a specific Symbol style, you could issue the Set Style statement before calling CreatePoint(). Alternately, instead of calling CreatePoint(), you could issue a Create Point statement, which has an optional Symbol clause.

The point object created through the CreatePoint() function could be assigned to an Object variable, stored in an existing row of a table (through the Update statement), or inserted into a new row of a table (through an Insert statement).

Note: If you need to create objects on a Layout window, you must first issue a Set CoordSys statement.

Examples

The following example uses the Insert statement to insert a new row into the table Sites. The CreatePoint() function is used within the body of the Insert statement to specify the graphic object that will be attached to the new row.

Open Table "sites"
Insert Into sites (obj)
	Values ( CreatePoint(-72.5, 42.4) ) 

The following example assumes that the table Sites has Xcoord and Ycoord columns, which indicate the longitude and latitude positions of the data. The Update statement uses the CreatePoint() function to build a point object for each row in the table. Following the Update operation, each row in the Sites table will have a point object attached. Each point object will be located at the position indicated by the Xcoord, Ycoord columns.

Open Table "sites"
Update sites 
	Set obj = CreatePoint(xcoord, ycoord)

The above example assumes that the Xcoord, Ycoord columns contain actual longitude and latitude degree values.

See Also:

Create Point statement, Insert statement, Update statement