Įvykiai
Kurti DI programėles ir agentus
03-17 21 - 03-21 10
Prisijunkite prie meetup serijos, kad sukurtumėte keičiamo dydžio DI sprendimus, pagrįstus realaus pasaulio naudojimo atvejais, su kolegomis kūrėjais ir ekspertais.
Registruotis dabarŠi naršyklė nebepalaikoma.
Atnaujinkite į „Microsoft Edge“, kad pasinaudotumėte naujausiomis funkcijomis, saugos naujinimais ir techniniu palaikymu.
APPLIES TO:
MongoDB vCore
Geospatial data can now be stored and queried using vCore-based Azure Cosmos DB for MongoDB. This enhancement provides powerful tools to manage and analyze spatial data, enabling a wide range of applications such as real-time location tracking, route optimization, and spatial analytics.
Here’s a quick overview of the geospatial commands and operators now supported:
Selects documents where a specified geometry intersects with the documents' geometry. Useful for finding documents that share any portion of space with a given geometry.
db.collection.find({
location: {
$geoIntersects: {
$geometry: {
type: "<GeoJSON object type>",
coordinates: [[[...], [...], [...], [...]]]
}
}
}
})
Selects documents with geospatial data that exists entirely within a specified shape. This operator is used to find documents within a defined area.
db.collection.find({
location: {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [[[...], [...], [...], [...]]]
}
}
}
})
Defines a rectangular area using two coordinate pairs (bottom-left and top-right corners). Used with the $geoWithin
operator to find documents within this rectangle. For example, finding all locations within a rectangular region on a map.
db.collection.find({
location: {
$geoWithin: {
$box: [[lowerLeftLong, lowerLeftLat], [upperRightLong, upperRightLat]]
}
}
})
Defines a circular area using a center point and a radius in radians. Used with the $geoWithin
operator to find documents within this circle.
db.collection.find({
location: {
$geoWithin: {
$center: [[longitude, latitude], radius]
}
}
})
Similar to $center
, but defines a spherical area using a center point and a radius in radians. Useful for spherical geometry calculations.
db.collection.find({
location: {
$geoWithin: {
$centerSphere: [[longitude, latitude], radius]
}
}
})
Specifies a GeoJSON object to define a geometry. Used with geospatial operators to perform queries based on complex shapes.
db.collection.find({
location: {
$geoIntersects: {
$geometry: {
type: "<GeoJSON object type>",
coordinates: [longitude, latitude]
}
}
}
})
Specifies the maximum distance from a point for a geospatial query. Used with $near
and $nearSphere
operators. For example, finding all locations within 2 km of a given point.
db.collection.find({
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [longitude, latitude]
},
$maxDistance: distance
}
}
})
Specifies the minimum distance from a point for a geospatial query. Used with $near
and $nearSphere
operators.
db.collection.find({
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [longitude, latitude]
},
$minDistance: distance
}
}
})
Defines a polygon using an array of coordinate pairs. Used with the $geoWithin
operator to find documents within this polygon.
db.collection.find({
location: {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [[[...], [...], [...], [...]]]
}
}
}
})
Finds documents that are near a specified point. Returns documents sorted by distance from the point. For example, finding the nearest restaurants to a user's location.
db.collection.find({
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [longitude, latitude]
},
$maxDistance: distance
}
}
})
Similar to $near
, but performs calculations on a spherical surface. Useful for more accurate distance calculations on the Earth's surface.
db.collection.find({
location: {
$nearSphere: {
$geometry: {
type: "Point",
coordinates: [longitude, latitude]
},
$maxDistance: distance
}
}
})
Performs a geospatial query to return documents sorted by distance from a specified point. Can include additional query criteria and return distance information.
db.collection.aggregate([
{
$geoNear: {
near: {
type: "Point",
coordinates: [longitude, latitude]
},
distanceField: "distance",
spherical: true
}
}
])
Currently, querying with a single-ringed GeoJSON polygon whose area exceeds a single hemisphere isn't supported. In such cases, Mongo vCore returns the following error message:
Error: Custom CRS for big polygon is not supported yet.
A composite index using a regular index and geospatial index isn't allowed. For example:
db.collection.createIndex({a: "2d", b: 1});
Error: Compound 2d indexes are not supported yet
Polygons with holes are currently not supported for use with $geoWithin queries. Although inserting a polygon with holes is not restricted, it eventually fails with the following error message:
Error: $geoWithin currently doesn't support polygons with holes
The key field is always required in the $geoNear aggregation stage. If the key field is missing, the following error occurs:
Error: $geoNear requires a 'key' option as a String
The $geoNear
, $near
, and $nearSphere
stages don't have strict index requirements, so these queries wouldn't fail if an index is missing.
Įvykiai
Kurti DI programėles ir agentus
03-17 21 - 03-21 10
Prisijunkite prie meetup serijos, kad sukurtumėte keičiamo dydžio DI sprendimus, pagrįstus realaus pasaulio naudojimo atvejais, su kolegomis kūrėjais ir ekspertais.
Registruotis dabarMokymas
Modulis
Implement vCore-based Azure Cosmos DB for MongoDB - Training
Implement vCore-based Azure Cosmos DB for MongoDB.
Sertifikatas
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.