I went to an interview yesterday.
Asked for a moment Mong.
I remember Mong supported the geo-index, and said a bit.
And then the interviewer says how many meters to look at a certain point, how can this be achieved? I was so confused ....
Go back and check it out. Test data found (metric Yes)
Bsonelement Bsonele = new Bsonelement ("Address", "Nanjing Zhonghua Gate");
/*
* Create test data:
Db.mapinfo.insert ({"Address": "Nanjing Lukou International Airport", "Loc": {"type": "Point", "coordinates": [118.783799, 31.979234]})
Db.mapinfo.insert ({"Address": "Nanjing Pukou Park", "Loc": {"type": "Point", "coordinates": [ 118.639523,32.070078]})
Db.mapinfo.insert ({"Address": "Nanjing railway Station", "Loc": {"type": "Point", "coordinates": [ 118.803032,32.09248]})
Db.mapinfo.insert ({"Address": "Nanjing Xinjiekou", "loc": {"type": "Point", "coordinates": [ 118.790611,32.047616]})
Db.mapinfo.insert ({"Address": "Nanjing Zhang Fu Yuan", "loc": {"type": "Point", "coordinates": [ 118.790427,32.03722]})
Db.mapinfo.insert ({"Address": "Nanjing Sanshan Street", "Loc": {"type": "Point", "coordinates": [ 118.788135,32.029064]})
Db.mapinfo.insert ({"Address": "Nanjing Zhonghua Gate", "loc": {"type": "Point", "coordinates": [ 118.781161,32.013023]})
Db.mapinfo.insert ({"Address": "Nanjing Ender Gate", "loc": {"type": "Point", "coordinates": [ 118.768964,31.99646]})
* */
Mong_sql
/*
* Db.mapinfo.find (
* {
* "LOC":
* {
* "$near":
* {
* "$geometry":
* {
* "type": "Point", "coordinates": [118.783799, 31.979234]
* },
* "$maxDistance": 5000
}
*}
*}
*). Limit (50);
*/
Point of query
Double[] Array = {118.803032, 32.09248};
Bsonvalue bs = bsonvalue.create (array);
Bsonelement Bsonele = new Bsonelement ("coordinates", BS);
var query = new Querydocument ("type", "point");
Query. ADD (Bsonele);
var query1 = new Querydocument ("$geometry", query);
Distance from the point of how many meters
Query1. ADD ("$maxDistance", 50000);
var query2 = new Querydocument ("$near", Query1);
var query3 = new Querydocument ("Loc", Query2);
Imongoquery q= query.eq ("coordinates", BS);
mongocursor<mapinfo> mi = _mapinfos. Find (Query3). Setlimit (50);
Feel:
1: Keep adding objects to the object as well as objects in the MONGO.
The 2:ado executes SQL statements for the server, and Mongo.driver executes Bson.
MONGO queries how many meters away from a point to thank for the data provided. Thanks to the MVC demo. It's all kind of a thank-you document anyway.