geoIntersects

abstract fun geoIntersects(geometry: Geo)(source)

Matches documents whose geospatial data intersects with the given geometry.

This operator should only be called on fields containing GeoJSON data.

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)),
)
)
}
}

Indexing

This operator does not require a 2dsphere index. However, such an index is recommended for performance.

External resources


abstract fun geoIntersects(polygon: Geo.Polygon, crs: Geo.CoordinateReferenceSystem? = null)(source)

Matches documents whose geospatial data intersects with the given polygon.

This operator should only be called on fields containing GeoJSON data.

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.

External resources