Skip to content

Commit

Permalink
Merge branch 'gis-based-mode-detection' of https://github.com/e-missi…
Browse files Browse the repository at this point in the history
…on/e-mission-server into gis-based-mode-detection
  • Loading branch information
shankari committed Sep 13, 2023
2 parents 698a634 + f78a22b commit 8b7645c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions emission/tests/storageTests/TestMongoGeoJSONQueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ def testGeoWithinPostsData(self):
self.assertEqual(retVal[0]['text'], "My first blog post!")
self.assertEqual(retVal[0]['loc']['coordinates'], [100,32])

def testGeoWithinCounts(self):
post1 = {"author": "Mike",
"text": "My first blog post!",
"tags": ["mongodb", "python", "pymongo"],
'loc':{'type':'Point', 'coordinates':[100,32]}}
self.Sections.insert_one(post1)
post2 = {"author": "hh",
"text": "My 2 blog post!",
"tags": ["mongodb", "python", "pymongo"],
"loc":{'type':'Point', 'coordinates':[200,30]}}
self.Sections.insert_one(post2)

retVal = []
matching_counts = self.Sections.count_documents({ "loc" : { "$geoWithin" : { "$polygon" :[ [ 90,31 ],[90,40] ,[ 110,40 ],[110,31]] } } })

self.assertEqual(matching_counts, 1)

def getTestPolygon(self):
return [ [ 90.234,-31.0323 ],[95.0343,-45.03453] ,[ 110.02322,-43.3435 ],[100.343423,-33.33423]]

Expand Down

0 comments on commit 8b7645c

Please sign in to comment.