geoWithin

Matches documents where a Geo.Point is within the given polygon.

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


abstract fun Field<T, Geo.Point>.geoWithin(polygons: Geo.MultiPolygon)(source)

Matches documents where a Geo.Point is within the given polygons.

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.

External resources