app/models/place.rb
# Update this place's bbox from a geometry.  Note this skips validations, 
# but explicitly recalculates the bbox area
Update this place's bbox from a geometry.  Note this skips validations,
but explicitly recalculates the bbox area
Update this place ' s bbox from a geometry . Note this skips validations but explicitly recalculates the bbox area
def update_bbox_from_geom(geom)
    self.longitude = geom.envelope.center.x
    self.latitude = geom.envelope.center.y
    self.swlat = geom.envelope.lower_corner.y
    self.nelat = geom.envelope.upper_corner.y
    if geom.spans_dateline?
      self.longitude = geom.envelope.center.x + 180*(geom.envelope.center.x > 0 ? -1 : 1)
      self.swlng = geom.points.map(&:x).select{|x| x > 0}.min
      self.nelng = geom.points.map(&:x).select{|x| x < 0}.max
    else
      self.swlng = geom.envelope.lower_corner.x
      self.nelng = geom.envelope.upper_corner.x
    end
    calculate_bbox_area
    save(:validate => false)
  end
def update_bbox_from_geom ( geom ) self . longitude = geom . envelope . center . x self . latitude = geom . envelope . center . y self . swlat = geom . envelope . lower_corner . y self . nelat = geom . envelope . upper_corner . y if geom . spans_dateline? self . longitude = geom . envelope . center . x + 180 * ( geom . envelope . center . x > 0 ? - 1 : 1 ) self . swlng = geom . points . map ( & :x ) . select { | x | x > 0 } . min self . nelng = geom . points . map ( & :x ) . select { | x | x < 0 } . max else self . swlng = geom . envelope . lower_corner . x self . nelng = geom . envelope . upper_corner . x end calculate_bbox_area save ( :validate => false ) end
Update this place's bbox from a geometry.
Update this place ' s bbox from a geometry .
geom