[SERVER-23143] Can't find by 2dsphere MultiPoint field Created: 15/Mar/16  Updated: 17/Mar/16  Resolved: 17/Mar/16

Status: Closed
Project: Core Server
Component/s: Geo, Querying
Affects Version/s: 3.3.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Alexey Plotnik Assignee: Kelsey Schubert
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2016-03-16 16.21.34.png    
Operating System: ALL
Participants:

 Description   

I have one document with MultiPoint field. Field has one point inside:

{
    "_id" : ObjectId("56e7e24cb1b31934cdce1a0e"),
    "geo_segments" : {
        "type" : "MultiPoint",
        "coordinates" : [ 
            [ 
                42.64248, 
                42.64248
            ]
        ]
    }
}

I nserted it like that:

db.test.insert({    "geo_segments" : {
        "type" : "MultiPoint",
        "coordinates" : [ 
            [ 
                42.64248, 
                42.64248
            ]
        ]
    }})

Field is indexed with 2dsphere index:

db.test.ensureIndex({"geo_segments": "2dsphere"})

When I run find() with the bounding window (counter clock-wise region:

db.test.find({
    "geo_segments": {
      $geoWithin: {
        $geometry: {
          type : "Polygon" ,
          coordinates: [[[-38.0, 40.0], [97.0, 40.0], [97.0, 50.0], [-38.0, 50.0],[-38.0, 40.0]]]
        }
      }
    }
})

nothing is found.

I have even try it with CRS without result:

db.test.find({
    "geo_segments": {
      $geoWithin: {
        $geometry: {
          type : "Polygon" ,
          coordinates: [[[-38.0, 40.0], [97.0, 40.0], [97.0, 50.0], [-38.0, 50.0],[-38.0, 40.0]]],
          "crs": {
              type:"name",
              properties: {
                  name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"
              }
          }
        }
      }
    }
})



 Comments   
Comment by Alexey Plotnik [ 17/Mar/16 ]

Oh my god, thanks a lot!

Comment by Kelsey Schubert [ 17/Mar/16 ]

Hi odiszapc,

This is expected behavior and a result of map distortion.

Please see the screenshot attached to this ticket for a visualization of the polygon specified in your query and the point you expect to be returned. As you can see, as result of this distortion, the point does not fall within the polygon.

For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Kind regards,
Thomas

Comment by Alexey Plotnik [ 17/Mar/16 ]

Please, let me know if additional information is needed.

Comment by Ramon Fernandez Marina [ 16/Mar/16 ]

Thanks for your report odiszapc, we're investigating.

Comment by Alexey Plotnik [ 15/Mar/16 ]

The point is inside the boundary. What I'm doing wrong?

Comment by Alexey Plotnik [ 15/Mar/16 ]

Is it ok for MultiPoint to have only one coordinate?

Comment by Alexey Plotnik [ 15/Mar/16 ]

My Mongo is 3.3.1

Generated at Thu Feb 08 04:02:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.