Ticket #648: positions.patch

File positions.patch, 3.3 KB (added by osm@…, 13 years ago)
  • rails_port/app/models/node.rb

     
    1717  end
    1818
    1919  def in_world?
    20     return false if self.lat < -90 or self.lat > 90
    21     return false if self.lon < -180 or self.lon > 180
     20    return false if self.lat <= -90 or self.lat >= 90
     21    return false if self.lon <= -180 or self.lon >= 180
    2222    return true
    2323  end
    2424
  • rails_port/app/controllers/api_controller.rb

     
    3838
    3939    bbox = bbox.split(',')
    4040
    41     min_lon = bbox[0].to_f
    42     min_lat = bbox[1].to_f
    43     max_lon = bbox[2].to_f
    44     max_lat = bbox[3].to_f
     41    min_lon = [bbox[0].to_f,-180].max
     42    min_lat = [bbox[1].to_f,-90].max
     43    max_lon = [bbox[2].to_f,+180].min
     44    max_lat = [bbox[3].to_f,+90].min
    4545
    46     # check the bbox is sane
    47     unless min_lon <= max_lon
     46    # Check the bbox is sane. As long as any part is inside, we accept it
     47    unless max_lon > -180 && max_lat > -90 && min_lon < 180 && min_lat < 90
     48      report_error("The latitudes must be between -90 and 90, and longitudes between -180 and 180")
     49      return
     50    end
     51    unless min_lon < max_lon
    4852      report_error("The minimum longitude must be less than the maximum longitude, but it wasn't")
    4953      return
    5054    end
    51     unless min_lat <= max_lat
     55    unless min_lat < max_lat
    5256      report_error("The minimum latitude must be less than the maximum latitude, but it wasn't")
    5357      return
    5458    end
    55     unless min_lon >= -180 && min_lat >= -90 && max_lon <= 180 && max_lat <= 90
    56       report_error("The latitudes must be between -90 and 90, and longitudes between -180 and 180")
    57       return
    58     end
    5959
    6060    # check the bbox isn't too large
    6161    requested_area = (max_lat-min_lat)*(max_lon-min_lon)
     
    110110
    111111    bbox = bbox.split(',')
    112112
    113     min_lon = bbox[0].to_f
    114     min_lat = bbox[1].to_f
    115     max_lon = bbox[2].to_f
    116     max_lat = bbox[3].to_f
     113    min_lon = [bbox[0].to_f,-180].max
     114    min_lat = [bbox[1].to_f,-90].max
     115    max_lon = [bbox[2].to_f,+180].min
     116    max_lat = [bbox[3].to_f,+90].min
    117117
    118     # check the bbox is sane
    119     unless min_lon <= max_lon
     118    # Check the bbox is sane. As long as any part is inside, we accept it
     119    unless max_lon > -180 && max_lat > -90 && min_lon < 180 && min_lat < 90
     120      report_error("The latitudes must be between -90 and 90, and longitudes between -180 and 180")
     121      return
     122    end
     123    unless min_lon < max_lon
    120124      report_error("The minimum longitude must be less than the maximum longitude, but it wasn't")
    121125      return
    122126    end
    123     unless min_lat <= max_lat
     127    unless min_lat < max_lat
    124128      report_error("The minimum latitude must be less than the maximum latitude, but it wasn't")
    125129      return
    126130    end
    127     unless min_lon >= -180 && min_lat >= -90 && max_lon <= 180 && max_lat <= 90
    128       report_error("The latitudes must be between -90 and 90, and longitudes between -180 and 180")
    129       return
    130     end
    131131
    132132    # check the bbox isn't too large
    133133    requested_area = (max_lat-min_lat)*(max_lon-min_lon)