I'm just trying out some stuff with GeoJSON's by figuring out how to import them into MongoDB. Here is a snippet of the JSON data that I'm trying to import:
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"source": "© GeoBasis-DE / BKG 2013 (Daten verändert)",
"features": [
{
"type": "Feature",
"properties": {
"RS": "051580004004",
"DES": "Stadt",
"GEN": "Erkrath",
"EWZ_M": 20929,
"EWZ_W": 22883,
"SHAPE_AREA": 26441754.911268
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
6.88238674728364,
51.24166234476658
],
[
6.881975279589705,
51.23757802188462
],
[
6.891756626701045,
51.23929422878399
],
[
6.903180857084263,
51.23707789012778
],
[
6.908259412237354,
51.24206723420193
],
[
6.918977412277895,
51.24041847413137
],
[
6.926662904165135,
51.24253596694298
],
[
6.937590326994132,
51.23093391057761
],
[
6.94295724765998,
51.2299892278866
],
[
6.939417113978845,
51.227341409094315
],
[
6.951333593915336,
51.22740615125517
],
[
6.950253526637431,
51.224656373607054
],
[
6.955765647972802,
51.22167757046095
],
[
6.964606469495985,
51.22457614378809
],
[
6.975480633820623,
51.223046741435965
],
[
6.973404761769492,
51.22089502422256
],
[
6.980214287180364,
51.21998473062592
],
[
6.982741542191386,
51.214167748907066
],
[
6.994804384322499,
51.215655729126155
],
[
6.994747626413055,
51.21224925095131
],
[
6.985928005605313,
51.20743852466108
],
[
6.98828820437737,
51.20347146797952
],
[
6.944606700602787,
51.198908942197114
],
[
6.943253716046289,
51.19637267292547
],
[
6.937329237188316,
51.19846226521679
],
[
6.932905519738434,
51.194111787062006
],
[
6.907388585403191,
51.19594285093562
],
[
6.903803051706552,
51.20313804926765
],
[
6.910551758112292,
51.21099091708282
],
[
6.878932812936605,
51.21491884904021
],
[
6.872564112818471,
51.219486802570856
],
[
6.873244797535404,
51.226155851357795
],
[
6.878496898776498,
51.22869664243089
],
[
6.872981880136851,
51.232966792978665
],
[
6.871618163754948,
51.24209470504303
],
[
6.88238674728364,
51.24166234476658
]
]
]
}
},
{
"type": "Feature",
"properties": {
"RS": "051160000000",
"DES": "Stadt",
"GEN": "Mönchengladbach",
"EWZ_M": 123662,
"EWZ_W": 131172,
"SHAPE_AREA": 170540962.920759
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
.....
.....
I want now to import this data into my MongoDB instance. When I tried the following, I ran into some errors:
mongoimport --db /Users/joe/mongodb-data -c points --file "gemeinden_simplify200.geojson" --jsonArray
connected to: 127.0.0.1
assertion: 13106 nextSafe(): { $err: "Invalid ns [/Users/joe/mongodb-data.points]", code: 16256 }
I think you need to try-
mongoimport --db test -c points --file "gemeinden_simplify200.geojson" --jsonArray
Here test is database name.
Related
I am trying to combine multiple filters on MapBox GL JS v1.9.1. The filter is -- if property "d" is between 2 integers AND property "i" has one of the given values AND if the point falls within a Polygon. The filter expression is as follows -
[
"all",
[
">=",
[
"get",
"d"
],
1577854800
],
[
"<=",
[
"get",
"d"
],
1577941199
],
[
"match",
[
"get",
"i"
],
[
"bdba680267591d0543072cf18cd98e57",
"c42c6d59e302b45e5fb6be6e8abdfcbb",
"2b34c7d0c8fe7021eae2cf8b693f6d14",
"bcbce48c922fdd706094d80f6f6efa5a"
],
true,
false
],
[
"==",
[
"within",
[
"object",
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-73.96644912936983,
40.7579747
],
[
-73.96790253328018,
40.76354671807032
],
[
-73.96870366224104,
40.76483841792908
],
[
-73.98926755133365,
40.77225531118752
],
[
-73.99108514195954,
40.771908119615176
],
[
-73.99284935487653,
40.77142674159516
],
[
-73.99454319974974,
40.77081581306094
],
[
-73.99615036392716,
40.770081217588285
],
[
-74.00454413035031,
40.75940186729005
],
[
-74.00463607063017,
40.7579747
],
[
-73.97078314761191,
40.74873768960421
],
[
-73.96966695937762,
40.749885383567914
],
[
-73.96870366224104,
40.75111098207092
],
[
-73.96790253328018,
40.752402681929674
],
[
-73.96727128780488,
40.753748043368425
],
[
-73.96681600505411,
40.75513410982106
],
[
-73.9665410696497,
40.756547532709945
],
[
-73.96644912936983,
40.7579747
]
]
]
}
}
]
}
]
],
true
]
]
The filter does not apply but if I remove "within" from the expression, the filter works fine. The "within" expression works perfectly just on its own as well but fails in the above case.
Any insights on how to solve this?
Nested 'within' filter was a bug and fixed.
I am attempting to write a query builder for aggrigation's ( Our app has one for the find api, and we have some use cases where aggrigation's are needed )
in find one example we use it for is for pre-filtering document's to only one's they should have access to ( Reduces the load on our auth system ), But I can not seem to find a way to do that with aggregation
How would I re-write this in an aggrigation pipeline?
db.collection.find({
participants: {
"$elemMatch": {
scopes: {
"$in": [
"READWRITE",
"READ",
"OWNER"
],
"$nin": [
"EXCLUDE"
]
},
module_id: {
"$in": [
"bdc1ab4d-8c58-48cb-b811-e42a0d778df3",
"e0f26978-37ea-4415-9213-fb48dbfc3630"
]
}
}
}
})
Example Doc's
{
"title": "One Document",
"participants": [
{
"id": "2464b4a6-96c1-4dca-b764-34e424499e9f",
"module_name": "USER",
"module_id": "bdc1ab4d-8c58-48cb-b811-e42a0d778df3",
"roles": [
"MEMBER"
],
"scopes": [
"OWNER"
],
},
{
"id": "e0e58850-a6ce-4b89-a527-71bcdd57014a",
"module_name": "ORGANIZATION",
"module_id": "e0f26978-37ea-4415-9213-fb48dbfc3630",
"roles": [
"MEMBER"
],
"scopes": [
"READWRITE"
],
}
]
},
{
"title": "another document",
"participants": [
{
"id": "9edae792-6fdd-47f4-900d-e6bc11fa8e7a",
"module_name": "USER",
"module_id": "579b4b72-5dba-4d0c-bf21-2982e0a2ff94",
"roles": [
"MEMBER"
],
"scopes": [
"OWNER"
],
},
{
"id": "b72eea73-837d-492d-aa11-d0edb994b6ee",
"module_name": "USER",
"module_id": "bdc1ab4d-8c58-48cb-b811-e42a0d778df3",
"roles": [
"MEMBER"
],
"scopes": [
"READWRITE"
],
},
{
"id": "cae84997-079f-4a2b-9b4d-f1b4f152f697",
"module_name": "ORGANIZATION",
"module_id": "25b3a235-f6c3-45d6-b64b-bb1e48639bfb",
"roles": [
"MEMBER"
],
"scopes": [
"READWRITE"
],
}
]
}
The same can be done in the aggregation pipeline using $match.
db.collection.aggregate([
{
$match:{
"participants":{
$elemMatch:{
"scopes":{
$in:[ 'READWRITE', 'READ', 'OWNER' ],
$nin:[ 'EXCLUDE' ]
},
"module_id":{
$in:[ 'bdc1ab4d-8c58-48cb-b811-e42a0d778df3','e0f26978-37ea-4415-9213-fb48dbfc3630' ]
}
}
}
}
}
]).pretty()
I have a bus network with 2 GeoJSONs : one for stations (points) and the other for lines between them.
I have 3 selects :first one to select the bus line and filter the stations on the other two that are for origin and destination stations.
What I want to do is to dynamically filter the bus lines on the first select and the bus stations on the last two selects.
Something like this :
User selects L1 on first select > Map only shows Line 1 (both geojsons, points and lines) and hide the other Lines that were showing.
User selects Station x on select 2 and Station y on select 3 > Map only shows these stations and the ones in between (both geojsons, points and lines).
Stations GeoJSON (not complete) :
var station ={
"type": "FeatureCollection",
"name": "test",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 0, "nom": "JAMAA EL FNA", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -7.991506070410076, 31.624380871588261 ] } },
{ "type": "Feature", "properties": { "id": 1, "nom": "KOUTOUBIA", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -7.993921192850516, 31.62551706188404 ] } },
{ "type": "Feature", "properties": { "id": 2, "nom": "HOTE DE VILLE", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -7.997800602958748, 31.627492814514493 ] } },
{ "type": "Feature", "properties": { "id": 3, "nom": "R.P BERDII", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -8.003733858117105, 31.630010280990067 ] } },
{ "type": "Feature", "properties": { "id": 4, "nom": "GRAND POSTE", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -8.009040991276375, 31.633004916540266 ] } },
{ "type": "Feature", "properties": { "id": 5, "nom": "CAREE EDEN", "ligne": "L1", "ville": "MARRAKECH", "direction": "A" }, "geometry": { "type": "Point", "coordinates": [ -8.011327830139466, 31.634311225216251 ] } },....
Lines GeoJSON (not complete) :
var lignemarrakech = {
"type": "FeatureCollection",
"name": "ligne",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 0, "ligne_bus": "L1", "direction": "A", "from_st": null, "to_st": null, "ville": "MARRAKECH" }, "geometry": { "type": "LineString", "coordinates": [ [ -7.991506070410076, 31.624380871588261 ], [ -7.99177772113954, 31.62455510452893 ], [ -7.992132146977649, 31.624680377597475 ], [ -7.992359514496435, 31.624737319845583 ], [ -7.992653754814866, 31.624862592668791 ], [ -7.993295733691442, 31.625147303003317 ], [ -7.993583286729908, 31.625306740410121 ], [ -7.993921192850516, 31.62551706188404 ] ] } },
{ "type": "Feature", "properties": { "id": 1, "ligne_bus": "L1", "direction": "A", "from_st": null, "to_st": null, "ville": "MARRAKECH" }, "geometry": { "type": "LineString", "coordinates": [ [ -7.993929771507931, 31.625520494421043 ], [ -7.993921192850516, 31.62551706188404 ], [ -7.994251765813826, 31.625734485234361 ], [ -7.994613027718003, 31.625968537122866 ], [ -7.994699416434219, 31.626022034614714 ], [ -7.995311990967388, 31.626396516196305 ], [ -7.995618278233972, 31.626550320694935 ], [ -7.995971686618494, 31.626730873477591 ], [ -7.99655284707304, 31.627018419778416 ], [ -7.997188982165176, 31.627279216817595 ], [ -7.997597365187289, 31.627433019856959 ], [ -7.997800602958748, 31.627492814514493 ] ] } },
{ "type": "Feature", "properties": { "id": 2, "ligne_bus": "L1", "direction": "A", "from_st": null, "to_st": null, "ville": "MARRAKECH" }, "geometry": { "type": "LineString", "coordinates": [ [ -7.997800602958748, 31.627492814514493 ], [ -7.998131404523898, 31.627586822642048 ], [ -7.998704711458787, 31.62774731223368 ], [ -7.999246604315053, 31.627847618087841 ], [ -7.999898446446502, 31.627981359058502 ], [ -8.000487460420704, 31.628188657183067 ], [ -8.001194277189745, 31.628529695028082 ], [ -8.001987482675004, 31.628984410209988 ], [ -8.00258435016886, 31.629345505977 ], [ -8.002796395199573, 31.629499305600273 ], [ -8.002835662797853, 31.629606296492579 ], [ -8.002859223356822, 31.629659791892589 ], [ -8.002906344474757, 31.629686539581062 ], [ -8.002984879671317, 31.629726661099347 ], [ -8.00307912190719, 31.629733348017368 ], [ -8.003181217662718, 31.629726661099347 ], [ -8.003401116213087, 31.629820277908031 ], [ -8.003733858117105, 31.630010280990067 ] ] } },...
This is what I could do for the first select :
$('#selectLine').on('change', function() {
console.log("chosen_line= " + this.value);
chosen_line = this.value;
filterLines();
if (chosen_line= 'L1'){
L.geoJSON(lignemarrakech, {
filter: function(feature, layer) {
return feature.properties.ligne='L1';
}
}).addTo(mymap);
}
else{
}
});
Beside the fact that it's not generalised, it doesn't work as intended (show only L1 when L1 is selected), it just display all the lines again on top.
if (chosen_line= 'L1')
should be
if (chosen_line == 'L1')
I'm working on PHP application that retrieves data from Adform API every day and saves them to Database.
There is a problem that data queried using dimensions, for example date and banner do not match totals, retrieved without dimensions.
For example, I make a POST to https://api.adform.com/v1/reportingstats/agency/reportdata
{
"metrics": ["ctr"],
"dimensions": ["date", "banner"],
"filter": {
"date":{
"from":"2016-08-01",
"to":"2016-08-30"
},
"campaign":{
"id":campaign_id
}
},
"paging":{
"page":1,
"pageSize":10000
}
}
Response is:
{
"reportData": {
"columnHeaders": [
"date",
"banner",
"ctr"
],
"columns": [
{
"key": "date"
},
{
"key": "banner"
},
{
"key": "ctr"
}
],
"rows": [
[
"2016-08-02T00:00:00",
"banner_1",
0.00816326530612245
],
[
"2016-08-03T00:00:00",
"banner_1",
0.0024213075060532689
],
[
"2016-08-03T00:00:00",
"banner_2",
0.001207653432082372
],
[
"2016-08-04T00:00:00",
"banner_1",
0.003472222222222222
],
[
"2016-08-04T00:00:00",
"banner_2",
0.000802886393241096
],
[
"2016-08-05T00:00:00",
"banner_1",
0
],
[
"2016-08-05T00:00:00",
"banner_2",
0.000676782107058102
],
[
"2016-08-06T00:00:00",
"banner_1",
0
],
[
"2016-08-06T00:00:00",
"banner_2",
0.000926995987708068
],
[
"2016-08-07T00:00:00",
"banner_1",
0.00904977375565611
],
[
"2016-08-07T00:00:00",
"banner_2",
0.0010050565441998231
],
[
"2016-08-08T00:00:00",
"banner_1",
0.0022935779816513758
],
[
"2016-08-08T00:00:00",
"banner_2",
0.000736000744868224
],
[
"2016-08-09T00:00:00",
"banner_1",
0.0052219321148825066
],
[
"2016-08-09T00:00:00",
"banner_2",
0.000636109173796044
],
[
"2016-08-10T00:00:00",
"banner_1",
0.0057971014492753624
],
[
"2016-08-10T00:00:00",
"banner_2",
0.000724849063441972
],
[
"2016-08-11T00:00:00",
"banner_1",
0
],
[
"2016-08-11T00:00:00",
"banner_2",
0.000581557986484298
],
[
"2016-08-12T00:00:00",
"banner_1",
0.0043103448275862068
],
[
"2016-08-12T00:00:00",
"banner_2",
0.000671168239505369
],
[
"2016-08-13T00:00:00",
"banner_1",
0
],
[
"2016-08-13T00:00:00",
"banner_2",
0.000803754549989838
],
[
"2016-08-14T00:00:00",
"banner_1",
0
],
[
"2016-08-14T00:00:00",
"banner_2",
0.000989294421086104
],
[
"2016-08-15T00:00:00",
"banner_1",
0.0064516129032258056
],
[
"2016-08-15T00:00:00",
"banner_2",
0.000638244734480941
],
[
"2016-08-16T00:00:00",
"banner_2",
0.000549180805298763
],
[
"2016-08-17T00:00:00",
"banner_2",
0.000551568224222697
],
[
"2016-08-18T00:00:00",
"banner_1",
0
],
[
"2016-08-18T00:00:00",
"banner_2",
0.000678091480705215
],
[
"2016-08-19T00:00:00",
"banner_2",
0
],
[
"2016-08-22T00:00:00",
"banner_2",
0.000360310246085577
],
[
"2016-08-23T00:00:00",
"banner_2",
0.000498299661680756
],
[
"2016-08-24T00:00:00",
"banner_2",
0.000561990345005873
],
[
"2016-08-25T00:00:00",
"banner_2",
0.000364882901395197
],
[
"2016-08-26T00:00:00",
"banner_2",
0.000372206184069575
],
[
"2016-08-27T00:00:00",
"banner_2",
0.000696784292763943
],
[
"2016-08-28T00:00:00",
"banner_2",
0.00084914217341799
],
[
"2016-08-29T00:00:00",
"banner_2",
0.000441720501352769
],
[
"2016-08-30T00:00:00",
"banner_2",
0.000556096204643403
]
]
}
}
So, total average CTR = 0.0015624820601283 = 0.15%
When I query without any dimensions:
{
"metrics": ["ctr"],
"filter": {
"date":{
"from":"2016-08-01",
"to":"2016-08-30"
},
"campaign":{
"id":campaign_id
}
},
"paging":{
"page":1,
"pageSize":10000
}
}
I get:
{
"reportData": {
"columnHeaders": [
"ctr"
],
"columns": [
{
"key": "ctr"
}
],
"rows": [
[
0.000729710843077063
]
]
}
}
CTR = 0.000729710843077063 = 0.07%
What is wrong?
Why such a difference: 0.15% vs 0.07%?
May be I should count CTR not by simple AVG but another way?
I also spotted the same issue with other APIs, such as Google Analytics API and Facebook Marketing API. Totals and averages counted locally using data sampled by dimensions are not always the same as totals provided by APIs themselves.
I have events in a collection, each containing a desired location, set a GeoJSON Polygon.
I also have service providers in another collection, also with a GeoJSON Polygon, indicating the area where they can deliver.
For a given service provider, I'm trying to list all the events that are in a compatible area.
However, I get this error:
Malformed geo query: { $geoIntersects: { $geometry: { type: "Polygon", coordinates: [ [ [ -31.59327575763251, 115.8574693000001 ], [ -31.59676306691357, 115.9162469300458 ], [ -31.60715789289806, 115.9738935747774 ], ...
My Polygons are closed (first and last coords are identical), so that's not coming from there.
Here are the events:
Events:
[
{
"_id": "5237d4bd9899e67c0e000004",
"area": "area",
"authtoken": "e3bf38ff9a1f132a7cc86ea045cf3951",
"budget": 1800,
"creation_date": {
"sec": 1379390653,
"usec": 0
},
"description": "Banana banana banana banana banana banana banana banana bananaaaaaaaaaaaaaaaaa!!!",
"ends": {
"sec": 1383343200,
"usec": 0
},
"geo": {
"type": "Polygon",
"coordinates": [
[
[
-33.740154878816,
150.9241267
],
[
-33.741901642057,
150.95422987078
],
[
-33.747108144055,
150.98375074498
],
[
-33.755673663135,
151.01211808166
],
[
-33.767432456928,
151.03878255704
],
[
-33.782156913661,
151.0632272399
],
[
-33.799561885809,
151.08497749366
],
[
-33.819310129033,
151.10361012448
],
[
-33.841018749004,
151.11876160464
],
[
-33.819310129033,
150.74464327552
],
[
-33.799561885809,
150.76327590634
],
[
-33.782156913661,
150.7850261601
],
[
-33.767432456928,
150.80947084296
],
[
-33.755673663135,
150.83613531834
],
[
-33.747108144055,
150.86450265502
],
[
-33.741901642057,
150.89402352922
],
[
-33.740154878816,
150.9241267
]
]
]
},
"guests": 180,
"loc": {
"city": "Liverpool",
"state": "NSW",
"country": "AU",
"lat": -33.9200192,
"lng": 150.9241267,
"timezone": "Australia\/Sydney"
},
"name": "Bananaaaaaaaa!",
"services": [
{
"creation_date": {
"sec": 1379390661,
"usec": 0
},
"data": {
"name": "Bananaaaaaaaaaaa!!!!!",
"request": "Banana!",
"description": " banana banana banana banana banana banana banana banana banana",
"budget": "1400"
},
"event": "aaca6751-75b2-4cd9-a76a-99d4ee56fb6a",
"service": "a9fe4bd0-d4f2-4f2c-8b81-4899ac19c44f",
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "15ceedd5-608b-48e4-8a05-b60ee4c4c5bb",
"type": "Food & Drinks"
}
],
"starts": {
"sec": 1383300000,
"usec": 0
},
"type": {
"_id": "521666701e6accf7afc1a0e3",
"icon": "uploads\/event-types\/icon-3891a6f4-760f-43f2-ab3a-a51c61fd8d0d.png?rnd=0.6323562911552134",
"name": "Meeting",
"uuid": "3891a6f4-760f-43f2-ab3a-a51c61fd8d0d"
},
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "aaca6751-75b2-4cd9-a76a-99d4ee56fb6a",
"within": {
"km": 20,
"addr": "liverpool, nsw"
}
},
{
"_id": "5237d50a9899e67c0e000005",
"area": "area",
"authtoken": "e3bf38ff9a1f132a7cc86ea045cf3951",
"budget": 1800,
"creation_date": {
"sec": 1379390730,
"usec": 0
},
"description": "Boo!!!",
"ends": {
"sec": 1383285600,
"usec": 0
},
"geo": {
"type": "Polygon",
"coordinates": [
[
[
-32.086853059112,
116.0081156
],
[
-32.088163946126,
116.03027505189
],
[
-32.092071203806,
116.05200507521
],
[
-32.098499107954,
116.07288445521
],
[
-32.1073230624,
116.09250825588
],
[
-32.118371984525,
116.11049558927
],
[
-32.131431584032,
116.12649694645
],
[
-32.146248475035,
116.14020095399
],
[
-32.330851613336,
116.10195418015
],
[
-32.289125251893,
115.86992020233
],
[
-32.2721989398,
115.86018847275
],
[
-32.254291845681,
115.85334073219
],
[
-32.235752983166,
115.84950870874
],
[
-32.098499107954,
115.94334674479
],
[
-32.092071203806,
115.96422612479
],
[
-32.088163946126,
115.98595614811
],
[
-32.086853059112,
116.0081156
]
]
]
},
"guests": 700,
"loc": {
"city": "Byford",
"state": "WA",
"country": "AU",
"zipcode": "6122",
"lat": -32.2217513,
"lng": 116.0081156,
"timezone": "Australia\/Perth"
},
"name": "Halloween",
"services": [
{
"creation_date": {
"sec": 1379390749,
"usec": 0
},
"data": {
"name": "Badass lighting",
"description": "Boom! I want that!",
"type": [
"Furniture",
"Lighting\/lasers",
"LED screens",
"Dancefloor"
],
"budget": "800"
},
"event": "a6c28e98-b647-4224-8bff-f0b7e5c453c3",
"service": "4d4f370e-5780-4794-b988-df9d7a9ed644",
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "217c4896-a986-4c0a-a6c7-46c9aa74cf27",
"type": "Equipment Hire"
}
],
"starts": {
"sec": 1383256800,
"usec": 0
},
"type": {
"_id": "521666701e6accf7afc1a0e3",
"icon": "uploads\/event-types\/icon-3891a6f4-760f-43f2-ab3a-a51c61fd8d0d.png?rnd=0.6323562911552134",
"name": "Meeting",
"uuid": "3891a6f4-760f-43f2-ab3a-a51c61fd8d0d"
},
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "a6c28e98-b647-4224-8bff-f0b7e5c453c3",
"within": {
"km": 15,
"addr": "byford"
}
}
]
And here is my query object:
db.events.find({
"geo": {
"$geoIntersects": {
"$geometry": {
"type": "Polygon",
"coordinates": [
[
[
-31.593275757633,
115.8574693
],
[
-31.596763066914,
115.91624693005
],
[
-32.087153956437,
116.25114123685
],
[
-32.13233852915,
116.22535569049
],
[
-32.174036124673,
116.19236795072
],
[
-32.304841443191,
115.76898154226
],
[
-32.290955790481,
115.7119268346
],
[
-31.841206471153,
115.45474133646
],
[
-31.794742552646,
115.4770638401
],
[
-31.751364552714,
115.50675244396
],
[
-31.711911850434,
115.5432228167
],
[
-31.677146863424,
115.58576206658
],
[
-31.607157892898,
115.74104502522
],
[
-31.596763066914,
115.79869166995
],
[
-31.593275757633,
115.8574693
]
]
]
}
}
}
})
What am I missing?
My query seems to be identical to the official mongodb doc for geo queries.
Thanks in advance!
Your coordinates are specified as [latitude, longitude]. MongoDB requires that you specify coordinates in the opposite order for 2dsphere geometry: [longitude, latitude].
Your query worked for me once I swapped the coordinate order.