I am writing a program that finds overlapping objects. I can't perform the AreaOverlap() function on objects that don't enclose an area (e.g. text, points) as the result would be meaningless.
Is there a way to select only records that have objects that are regions?
I have a function that checks whether an object is a region (see below) so I could loop through the objects and check them one-by-one but it would be more efficient to do this as part of a select statement.
My example function:
Function IsObjectRegion(ObjAlias As Object) As Logical
Do Case ObjectInfo(ObjAlias, OBJ_INFO_TYPE)
Case OBJ_TYPE_REGION,
OBJ_TYPE_RECT,
OBJ_TYPE_ROUNDRECT,
OBJ_TYPE_ELLIPSE
IsObjectRegion = True
Case Else
IsObjectRegion = False
End Case
End Function
Update: my final, working code using Peter's method and my function:
Include "mapbasic.def"
Declare Sub main
Declare Function IsObjectRegion(ByVal ObjAlias As Object) As Logical
Function IsObjectRegion(ByVal ObjAlias As Object) As Logical
Do Case ObjectInfo(ObjAlias, OBJ_INFO_TYPE)
Case OBJ_TYPE_REGION,
OBJ_TYPE_RECT,
OBJ_TYPE_ROUNDRECT,
OBJ_TYPE_ELLIPSE
IsObjectRegion = True
Case Else
IsObjectRegion = False
End Case
End Function
Sub Main
Select * from TargetTable Where obj into temp1 noselect
Select * from temp where IsObjectRegion(OBJ) into results noselect
Browse * from results
Close table temp
End Sub