geoWithin
Matches documents where a Geo.Point is within the given polygon.
This operator should only be called on fields of type Geo.Point.
Example
class Place(
val _id: ObjectId,
val name: String,
val location: Geo.Point,
val category: String,
)
places.find {
Place::location {
geoWithin(
Geo.Polygon(
Geo.Point(Longitude(-73.95), Latitude(40.80)),
Geo.Point(Longitude(-73.94), Latitude(40.79)),
Geo.Point(Longitude(-73.97), Latitude(40.79)),
Geo.Point(Longitude(-79.98), Latitude(40.76)),
Geo.Point(Longitude(-73.95), Latitude(40.80)),
)
)
}
}Indexing
This operator does not require a 2d or 2dsphere index. However, such an index is recommended for performance.
Big polygons
For queries that specify a polygon greater with areas greater than a single hemisphere, the default crs results in queries for the complimentary geometry.
In these cases, specify a crs of Geo.CoordinateReferenceSystem.MongoDB. Only single-ringed polygons are supported.
External resources
Matches documents where a Geo.Point is within the given polygons.
This operator should only be called on fields of type Geo.Point.
Indexing
This operator does not require a 2d or 2dsphere index. However, such an index is recommended for performance.
Big polygons
For queries that specify a polygon greater with areas greater than a single hemisphere, this operator matches the complimentary geometry.