CartesianPerimeter() 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 the perimeter of a graphical object. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

CartesianPerimeter( obj_expr , unit_name )

obj_expr is an object expression.

unit_name is a string representing the name of a distance unit (e.g., "km").

Return Value

Float

Description

The CartesianPerimeter() function calculates the perimeter of the obj_expr object. The Perimeter() function is defined for the following object types: ellipses, rectangles, rounded rectangles, and polygons. Other types of objects have perimeter measurements of zero.

The CartesianPerimeter() function will always return a value using a Cartesian algorithm. A value of -1 will be returned for data that is in a Latitude/Longitude coordinate system, since Latitude/Longitude data is not projected and not Cartesian.

The CartesianPerimeter() function returns a length measurement in the units specified by the unit_name parameter; for example, to obtain a length in miles, specify "mi" as the unit_name parameter. See the Set Distance Units statement for the list of valid unit names. CartesianPerimeter() returns approximate results when used on rounded rectangles. MapBasic calculates the perimeter of a rounded rectangle as if the object were a conventional rectangle.

Example

The following example shows how you can use the CartesianPerimeter() function to determine the perimeter of a particular geographic object.

Dim perim As Float
Open Table "world"
Fetch First From world
perim = CartesianPerimeter(world.obj, "km")
' The variable perim now contains 
' the perimeter of the polygon that's attached to
' the first record in the World table. 

You can also use the CartesianPerimeter() function within the Select statement. The following Select statement extracts information from the States table, and stores the results in a temporary table called Results. Because the Select statement includes the CartesianPerimeter() function, the Results table will include a column showing each state's perimeter.

Open Table "states"
Select state, CartesianPerimeter(obj, "mi")
	From states 
	Into results 

See Also:

CartesianPerimeter() function, SphericalPerimeter() function, Perimeter() function