Purpose
Returns coordinate or angle information describing a graphical object. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
ObjectGeography( object, attribute )
object is an Object expression.
attribute is an integer code specifying which type of information should be returned.
Return Value
Float
Description
The attribute parameter controls which type of information will be returned. The table below summarizes the different codes that you can use as the attribute parameter; codes in the left column (for example, OBJ_GEO_MINX) are defined in MAPBASIC.DEF.
Some attributes apply only to certain types of objects. For example, arc objects are the only objects with begin-angle or end-angle attributes, and text objects are the only objects with the text-angle attribute. If an object does not support z- or m-values, or a z- or m-value for this node is not defined, then an error is thrown.
attribute setting | ID | Return value (Float) |
---|---|---|
OBJ_GEO_MINX | 1 | Minimum x-coordinate of an object's minimum bounding rectangle (MBR), unless the object is a line; if the object is a line, returns same value as OBJ_GEO_LINEBEGX. |
OBJ_GEO_MINY | 2 | Minimum y-coordinate of object's MBR. For lines, returns OBJ_GEO_LINEBEGY value. |
OBJ_GEO_MAXX | 3 | Maximum x-coordinate of object's MBR. Does not apply to Point objects. For lines, returns OBJ_GEO_LINEENDX value. |
OBJ_GEO_MAXY | 4 | Maximum y-coordinate of the object's MBR. Does not apply to Point objects. For lines, returns OBJ_GEO_LINEENDY value. |
OBJ_GEO_ARCBEGANGLE | 5 | Beginning angle of an Arc object. |
OBJ_GEO_ARCENDANGLE | 6 | Ending angle of an Arc object. |
OBJ_GEO_LINEBEGX | 1 | X-coordinate of the starting node of a Line object. |
OBJ_GEO_LINEBEGY | 2 | Y-coordinate of the starting node of a Line object. |
OBJ_GEO_LINEENDX | 3 | X-coordinate of the ending node of a Line object. |
OBJ_GEO_LINEENDY | 4 | Y-coordinate of the ending node of a Line object. |
OBJ_GEO_POINTX | 1 | X-coordinate of a Point object. |
OBJ_GEO_POINTY | 2 | Y-coordinate of a Point object. |
OBJ_GEO_POINTZ | 8 | Z-value of a Point object. |
OBJ_GEO_POINTM | 9 | M-value of a Point object. |
OBJ_GEO_ROUNDRADIUS | 5 | Diameter of the circle that defines the rounded corner of a Rounded Rectangle object, expressed in terms of coordinate units (for example, degrees). |
OBJ_GEO_CENTROID | 5 | Returns a point object for centroid of regions, collections, multipoints, and polylines. This is most commonly used with the Alter Object statement. |
OBJ_GEO_TEXTLINEX | 5 | X-coordinate of the end of a Text object's label line. |
OBJ_GEO_TEXTLINEY | 6 | Y-coordinate of the end of a Text object's label line. |
OBJ_GEO_TEXTANGLE | 7 | Rotation angle of a Text object. |
The ObjectGeography() function has been extended to support Multipoints and Collections. Both types support attributes 1 - 4 (coordinates of object's minimum bounding rectangle (MBR).
OBJ_GEO_MINX | 1 | Minimum x-coordinate of an object's MBR. |
OBJ_GEO_MINY | 2 | Minimum y-coordinate of an object's MBR. |
OBJ_GEO_MAXX | 3 | Maximum x-coordinate of an object's MBR. |
OBJ GEO_MAXY | 4 | Maximum y-coordinate of an object's MBR. |
Example
The following example reads the starting coordinates of a line object from the table City. A Set Map statement then uses these coordinates to re-center the Map window.
Include "MAPBASIC.DEF"
Dim i_obj_type As Integer, f_x, f_y As Float
Open Table "city"
Map From city
Fetch First From city
' at this point, the expression:
' city.obj
' represents the graphical object that's attached
' to the first record of the CITY table.
i_obj_type = ObjectInfo(city.obj, OBJ_INFO_TYPE)
If i_obj_type = OBJ_LINE Then
f_x = ObjectGeography(city.obj, OBJ_GEO_LINEBEGX)
f_y = ObjectGeography(city.obj, OBJ_GEO_LINEBEGY)
Set Map Center (f_x, f_y)
End If
See Also:
Centroid() function, CentroidX() function, CentroidY() function, ObjectInfo() function