+ elsif db_min_lon <= db_max_lon
+ # the normal case when the query bbox doesn't include the antimeridian
+ changesets.where("min_lon < ? and max_lon > ?", db_max_lon, db_min_lon)
+ else
+ # the query bbox includes the antimeridian
+ # this case works as if there are two query bboxes:
+ # [-180*SCALE .. db_max_lon], [db_min_lon .. 180*SCALE]
+ # it would be necessary to check if changeset bboxes intersect with either of the query bboxes:
+ # (changesets.min_lon < db_max_lon and changesets.max_lon > -180*SCALE) or (changesets.min_lon < 180*SCALE and changesets.max_lon > db_min_lon)
+ # but the comparisons with -180*SCALE and 180*SCALE are unnecessary:
+ # (changesets.min_lon < db_max_lon) or (changesets.max_lon > db_min_lon)
+ changesets.where("min_lon < ? or max_lon > ?", db_max_lon, db_min_lon)