From 2329d789e998f3339ea286c0f8ab1b695883cb02 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Fri, 18 Aug 2023 01:20:42 -0400 Subject: [PATCH] mongo --- mongo/pipeline1.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ mongo/pipeline2.py | 15 +++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 mongo/pipeline1.py create mode 100644 mongo/pipeline2.py diff --git a/mongo/pipeline1.py b/mongo/pipeline1.py new file mode 100644 index 0000000..3aa6047 --- /dev/null +++ b/mongo/pipeline1.py @@ -0,0 +1,45 @@ +pipeline = [ + { + '$addFields': { + 'location': { + 'type': 'Point', + 'coordinates': [ + { + '$toDouble': '$latdec' + }, { + '$toDouble': '$londec' + } + ] + } + } + }, { + '$match': { + 'location': { + '$geoWithin': { + '$centerSphere': [ + [ + 35.9, -78.9 + ], 100 / 3963.2 + ] + } + } + } + }, { + '$project': { + '_id': 1, + 'recrd': 1, + 'vesslterms': 1, + 'feature_type': 1, + 'chart': 1, + 'latdec': 1, + 'londec': 1, + 'gp_quality': 1, + 'depth': 1, + 'sounding_type': 1, + 'history': 1, + 'quasou': 1, + 'watlev': 1, + 'coordinates': 1 + } + } +] diff --git a/mongo/pipeline2.py b/mongo/pipeline2.py new file mode 100644 index 0000000..7f9989f --- /dev/null +++ b/mongo/pipeline2.py @@ -0,0 +1,15 @@ +pipeline = [ + { + '$geoNear': { + 'near': { + 'type': 'Point', + 'coordinates': [ + -78.9, 35.9 + ] + }, + 'distanceField': 'distance', + 'maxDistance': 160934.4, + 'spherical': True + } + } +]