AWS documentdb documentation change
Summary
Added comprehensive documentation for the $geoIntersects operator in Amazon DocumentDB, including detailed examples in MongoDB Shell, Node.js, and Python with connection strings and usage patterns
Security assessment
This change adds documentation for a geospatial query operator ($geoIntersects) with standard usage examples. The code examples include TLS parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security best practices for DocumentDB connections, but this is not new security documentation - it's standard connection string formatting. There is no evidence this addresses a specific security vulnerability or incident.
Diff
diff --git a/documentdb/latest/developerguide/geoIntersects.md b/documentdb/latest/developerguide/geoIntersects.md index 8b1378917..bec327b71 100644 --- a//documentdb/latest/developerguide/geoIntersects.md +++ b//documentdb/latest/developerguide/geoIntersects.md @@ -0,0 +1 @@ +[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#geoIntersects "Open PDF") @@ -1,0 +3,177 @@ +[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html) + +Example (MongoDB Shell)Code examples + +# $geoIntersects + +The `$geoIntersects` operator in Amazon DocumentDB is used to find documents whose geospatial data intersects with a specified GeoJSON object. This operator is useful for applications that require identifying documents based on their spatial relationship with a given geographic shape, such as a polygon or multipolygon. + +**Parameters** + + * `$geometry`: A GeoJSON object that represents the shape to check for intersection. The supported GeoJSON object types are `Point`, `LineString`, `Polygon`, and `MultiPolygon`. + + + + +## Example (MongoDB Shell) + +The following example demonstrates how to use the `$geoIntersects` operator to find the state name for a given set of coordinates in Amazon DocumentDB. + +**Create sample documents** + + + db.states.insertMany([ + { + "name": "New York", + "loc": { + "type": "Polygon", + "coordinates": [[ + [-74.25909423828125, 40.47556838210948], + [-73.70819091796875, 40.47556838210948], + [-73.70819091796875, 41.31342607582222], + [-74.25909423828125, 41.31342607582222], + [-74.25909423828125, 40.47556838210948] + ]] + } + }, + { + "name": "California", + "loc": { + "type": "Polygon", + "coordinates": [[ + [-124.4091796875, 32.56456771381587], + [-114.5458984375, 32.56456771381587], + [-114.5458984375, 42.00964153424558], + [-124.4091796875, 42.00964153424558], + [-124.4091796875, 32.56456771381587] + ]] + } + } + ]); + +**Query example** + + + var location = [-73.965355, 40.782865]; + + db.states.find({ + "loc": { + "$geoIntersects": { + "$geometry": { + "type": "Point", + "coordinates": location + } + } + } + }, { + "name": 1 + }); + +**Output** + + + { "_id" : ObjectId("536b0a143004b15885c91a2c"), "name" : "New York" } + +## Code examples + +To view a code example for using the `$geoIntersects` command, choose the tab for the language that you want to use: + +Node.js + + + + const { MongoClient } = require('mongodb'); + + async function findStateByGeoIntersects(longitude, latitude) { + const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'); + const db = client.db('test'); + const collection = db.collection('states'); + + const query = { + loc: { + $geoIntersects: { + $geometry: { + type: 'Point', + coordinates: [longitude, latitude] + } + } + } + }; + + const projection = { + _id: 0, + name: 1 + }; + + const document = await collection.findOne(query, { projection }); + + await client.close(); + + if (document) { + return document.name; + } else { + throw new Error('The geo location you entered was not found in the United States!'); + } + } + +Python + + + + from pymongo import MongoClient + + def find_state_by_geointersects(longitude, latitude): + try: + client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') + db = client.test + collection_states = db.states + + query_geointersects = { + "loc": { + "$geoIntersects": { + "$geometry": { + "type": "Point", + "coordinates": [longitude, latitude] + } + } + } + } + + document = collection_states.find_one(query_geointersects, + projection={ + "_id": 0, + "name": 1 + }) + if document is not None: + state_name = document['name'] + return state_name + else: + raise Exception("The geo location you entered was not found in the United States!") + except Exception as e: + print('Exception in geoIntersects: {}'.format(e)) + raise + finally: + if client is not None: + client.close() + + **Javascript is disabled or is unavailable in your browser.** + +To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions. + +[Document Conventions](/general/latest/gr/docconventions.html) + +$geometry + +$geoWithin + +Did this page help you? - Yes + +Thanks for letting us know we're doing a good job! + +If you've got a moment, please tell us what we did right so we can do more of it. + +Did this page help you? - No + +Thanks for letting us know this page needs work. We're sorry we let you down. + +If you've got a moment, please tell us how we can make the documentation better.