geoIntersects
Matches documents whose geospatial data intersects with the given geometry.
Example
class GasStation(
val _id: ObjectId,
val name: String,
val loc: Geo.Point,
)
gasStations.find {
GasStation::loc.geoIntersects(
Geo.LineString(
Geo.Point(Longitude(-105.82), Latitude(33.87)),
Geo.Point(Longitude(-106.31), Latitude(35.65)),
Geo.Point(Longitude(-107.39), Latitude(35.98)),
)
)
}Content copied to clipboard
Indexing
This operator does not require a 2dsphere index. However, such an index is recommended for performance.
External resources
abstract fun Field<T, Geo>.geoIntersects(polygon: Geo.Polygon, crs: Geo.CoordinateReferenceSystem? = null)(source)
open fun KProperty1<T, Geo>.geoIntersects(polygon: Geo.Polygon, crs: Geo.CoordinateReferenceSystem? = null)(source)
Matches documents whose geospatial data intersects with the given polygon.
Indexing
This operator does not require a 2dsphere index. However, such an index is recommended for performance.
Big polygons
For queries that specify a polygon with an area greater than a single hemisphere, the default crs results in queries for the complementary geometry.
In these cases, specify a crs of Geo.CoordinateReferenceSystem.MongoDB. Only single-ringed polygons are supported.