This class represents a polygon on the surface of the earth. It cannot be persisted - i.e you can't declare a Realm property that is of type GeoPolygon. It can be only used as a query argument for a geospatial query.
A GeoPolygon describes a shape represented by 3 or more line segments. It comprises of one outer ring and 0 or more rings representing holes with the following restrictions:
Each ring must consist of at least 3 line segments. The first and the last point must be the same to indicate a closed ring (meaning you need at least 4 points to define the polygon).
Rings may not cross, i.e. the boundary of a ring may not intersect both the interior and exterior of any other ring.
Rings may not share edges, i.e. if a ring contains an edge AB, then no other ring may contain AB or BA.
Rings may share vertices, however no vertex may appear twice in a single ring.
No ring may be empty.
Holes may be nested inside each other, in which case a location will be considered "inside" the polygon if it is included in an odd number of rings, counting the outer ring as 1. For example, a polygon representing a square with side 10 centered at (0,0) with holes representing squares with sides 5 and 2, centered at (0,0) will include the location (1, 1) because it is contained in 3 rings, but not (3, 3), because it is contained in 2.
Using it can look something like this:
val searchArea = GeoPolygon.create(
outerRing = listOf(
holes = arrayOf(listOf(
val restaurants = realm.query<Restaurant>("location GEOWITHIN $0", searchArea).find()