Sha256: 00f4dfcaa80abf2f011e17dc047c0102f97bbd9966ffd8b4dfdeb123add0fdc8

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

module Georeferencer
  class Image
    include Georeferencer::Base
    self.preload_resources = true

    collection_path "display"
    resource_path "maps/:id"

    default_scope -> {
      where(format: 'json')
    }

    scope :unreferenced, -> {
      where(state: 'waiting')
    }
    
    def centroid
      # Data from the collection endpoint doesn't include the bounding box, so we need to check we have the full data,
      # or reload (which hits the resource endpoint) if not
      if respond_to?(:bbox)
        (wlng, slat, elng, nlat) = bbox
      else
        (wlng, slat, elng, nlat) = reload.bbox
      end
      {lat: (slat+nlat)/2, lng: (wlng+elng)/2}
    end

    def url(width=200,height=nil)
      [image[:url],'full',"#{width},#{height}",0,'default.jpg'].join("/")

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
georeferencer-0.1.3 lib/georeferencer/models/image.rb
georeferencer-0.1.2 lib/georeferencer/models/image.rb