-require "delegate"
-
module GeoRecord
extend ActiveSupport::Concern
# and not e.g. 4.0e-05
# Unfortunately you can't extend Numeric classes directly (e.g. `Coord < Float`).
class Coord < DelegateClass(Float)
- def initialize(obj)
- super(obj)
+ def to_s
+ format("%<coord>.7f", :coord => self)
end
- def to_s
- format("%.7f", self)
+ def as_json(_)
+ format("%<coord>.7f", :coord => self).to_f
end
end
SCALE = 10000000
included do
- scope :bbox, ->(bbox) { where(OSM.sql_for_area(bbox)) }
+ scope :bbox, ->(bbox) { where(OSM.sql_for_area(bbox, "#{table_name}.")) }
before_save :update_tile
end