Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14590

GeoQuery with BBOX near borders doesn't work

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.3
    • Geo
    • None
    • Ubuntu 14.04 , Mongo 2.6.3
    • Linux
    • Hide

      1) create 2dsphere index (mine is a composite index, I didn't try with simple 2dsphere)
      2) Populate your DB with a grid of rects like the classic long lat grid, e.g: a grid of rect with 1 unit side going from x=0,1,2,..180 , y=0,1..90 (my grid is not so regular but I think that won't effect the test)
      3) execute geoquery like this. It should get all the geoJSON (here i use 179.5 and 89.5 as limits):

      db.mycoll.find( { 
      	geometry :{ 
      		$geoIntersects : { 
      			$geometry :  { 
      				type : "Polygon" ,
      				coordinates : [ [ [-179.5, -89.5] , [ -179.5, 89.5 ] ,[179.5,-89.5] , [ 179.5, -89.5 ], [-179.5, -89.5]   ] ]                       
      			} 
      		} 
      	} 
      } ).count()

      5) compare it with db.mycoll.find().count()
      6) also $geoWithin query doesn't work as expected
      7) try on NE part of the world [0,0] , [179.9, 89.9] and look at the results.

      Show
      1) create 2dsphere index (mine is a composite index, I didn't try with simple 2dsphere) 2) Populate your DB with a grid of rects like the classic long lat grid, e.g: a grid of rect with 1 unit side going from x=0,1,2,..180 , y=0,1..90 (my grid is not so regular but I think that won't effect the test) 3) execute geoquery like this. It should get all the geoJSON (here i use 179.5 and 89.5 as limits): db.mycoll.find( { geometry :{ $geoIntersects : { $geometry : { type : "Polygon" , coordinates : [ [ [-179.5, -89.5] , [ -179.5, 89.5 ] ,[179.5,-89.5] , [ 179.5, -89.5 ], [-179.5, -89.5] ] ] } } } } ).count() 5) compare it with db.mycoll.find().count() 6) also $geoWithin query doesn't work as expected 7) try on NE part of the world [0,0] , [179.9, 89.9] and look at the results.

    Description

      If you try to find docs inside sphere limits (|x|<=179.9, |y|<89.9 as documentation says) you won't get expected results.
      This bug affects also "borders query", like if you want query for NE side of the world you get wrong results. bbox ( [0,0] , [179.9, 89.9] )

      Indexs:

      db.mycoll.getIndexes()
      [
      	{
      		"v" : 1,
      		"key" : {
      			"_id" : 1
      		},
      		"name" : "_id_",
      		"ns" : "grid_cluster.mycoll"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"geometry" : "2dsphere",
      			"properties.rank" : -1
      		},
      		"name" : "geometry_2dsphere_properties.rank_-1",
      		"ns" : "grid_cluster.mycoll",
      		"2dsphereIndexVersion" : 2
      	}
      ]

      One of my geoJSON docs:

      { "_id" : ObjectId("53c11c778bfd09820bdc997c"), "type" : "Feature",  "geometry" : { "type" : "Polygon", "coordinates" : [ [ [ 180, -33.75 ], [ 168.75, -33.75 ], [ 168.75, -28.125 ], [ 180, -28.125 ], [ 180, -33.75 ] ] ] }, "properties" : {  "rank" : 0 } }

      Attachments

        Activity

          People

            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            MikeQuaci Michael Quacinella [X]
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: