allanbank / mongodb-async-driver

The MongoDB Asynchronous Java Driver.
Apache License 2.0
22 stars 15 forks source link

Support creating GeoJSON objects with a Coordinate Reference System. #19

Open allanbank opened 9 years ago

allanbank commented 9 years ago

To support big polygons in MongoDB 3.0 they now support the addition of a Coordinate Reference System to GeoJSON documents. Currently the only supported CRS is:

This can only be used with query documents. e.g.,

var bigPoly = { 
    type : "Polygon", 
    coordinates : [ 
        [
            [-10.0, -10.0], 
            [10.0, -10.0],
            [10.0, 10.0], 
            [-10.0, 10.0], 
            [-10.0, -10.0]
        ]
    ], 
    crs : { 
        type : "name", 
        properties : { 
            name : "urn:x-mongodb:crs:strictwinding:EPSG:4326"
        }
    } 
}; 

var cursor = db.collection.find({ loc : { $geoWithin : { $geometry : bigPoly } } }); 
var cursor = db.collection.find({ loc : { $geoIntersects : { $geometry : bigPoly } } });