1

I'm using mongo to store some geolocalized data, with the goal of retriving them using $geointersect. Specifically I have this document stored in my db:

  {
    "loc": {
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -179.875,
              -89.875
            ],
            [
              179.875,
              -89.875
            ],
            [
              179.875,
              89.875
            ],
            [
              -179.875,
              89.875
            ],
            [
              -179.875,
              -89.875
            ]
          ]
        ]
      },
      "crs": {
        "type": "name",
        "properties": {
          "name": "urn:x-mongodb:crs:strictwinding:EPSG:4326"
        }
      },
      "type": "Feature",
      "properties": {}
    },
    "_id": "576af8e31d41c87fa1f1d04f"
  }

Which as you may notice covers almost the entire World. Now it doesn't matter what coordinates I input for my $geointersect query, it will never be returned... Does anyone know why?

An example of the query I'm using could be:

[
  {
    "loc.geometry": {
      "$geoIntersects": {
        "$geometry": {
          "type": "Polygon",
          "coordinates": [
            [
              [
                13.4307861328125,
                41.599013054830216
              ],
              [
                13.9801025390625,
                41.599013054830216
              ],
              [
                13.9801025390625,
                41.80407814427234
              ],
              [
                13.4307861328125,
                41.80407814427234
              ],
              [
                13.4307861328125,
                41.599013054830216
              ]
            ]
          ]
        }
      }
    }
  },
  {
    "loc": 1
  }
]

Of course the coordinates of the query are contained inside the polygon in the saved document (I mean... it's as big as the the world, duh!) but for some reason it doesn't find any match... I'm kinda lost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.