This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Written with pymongo-3.3 | |
author__ = 'mongolab' \ | |
import pymongo | |
import sys, datetime, time | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
name : "Timmy's Taco Truck", | |
loc : [ 37.7577 , -122.4376 ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.places.find( { loc : | |
{ $near : [ 100 , 100 ], | |
$maxDistance: 10 } | |
} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.places.find( { loc : | |
{ $geoWithin : | |
{ $polygon : | |
[ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] ] | |
} } } ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Point representation of Timmy's Taco Truck | |
{ | |
name : "Timmy's Taco Truck", | |
loc : { | |
type : "Point", | |
coordinates : [ 37.7577 , -122.4376 ] | |
} | |
} | |
// Polygon representation (Square) of a Food Truck Park |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.places.find( { loc : | |
{ $geoWithin : | |
{ $geometry : | |
{ type : "Polygon", | |
coordinates : [ [ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] , [ 0 , 0 ] ] ] | |
} } } } ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Invalid - Each point/vertex of the polygon is provided. | |
{ "type": "Polygon", | |
"coordinates": [ | |
[ [ 100.0 , 0.0 ] , [ 101.0 , 0.0 ] , [ 101.0 , 1.0 ] , [ 100.0 , 1.0 ] ] | |
] | |
} | |
//Valid - First vertex of the polygon is provided at both the beginning and end of a LinearRing. | |
{ "type": "Polygon", | |
"coordinates": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Recommended driver settings for the Mongoose 4.3.x driver. | |
var mongoose = require('mongoose'); | |
var uri = 'mongodb://<dbuser>:<dbpassword>@<host1>:<port1>,<host2>:<port2>/<dbname>?replicaSet=<replicaSetName>'; | |
var options = { | |
"server" : { | |
"socketOptions" : { | |
"keepAlive" : 300000, |