Sha256: e4c23365dfaed3f3bcaf9656afb5fc30e7ed477310297497ffae751caf746aa9

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Satellite
  module Landsat8
    class CoordinateConverterService
      include HTTParty
      base_uri 'https://landsatlook.usgs.gov/arcgis/rest/services/LLook_Outlines/MapServer/1'

      attr_accessor :lat, :lon

      def initialize(lat, lon)
        self.lat = lat
        self.lon = lon
      end

      def convert
        response = self.class.get('/query', {
          query: {
            where: "MODE='D'",
            geometry: "#{lon}, #{lat}",
            geometryType: 'esriGeometryPoint',
            spatialRel: 'esriSpatialRelIntersects',
            outFields: '*',
            returnGeometry: false,
            returnTrueCurves: false,
            returnIdsOnly: false,
            returnCountOnly: false,
            returnZ: false,
            returnM: false,
            returnDistinctValues: false,
            f: 'json'
          }.to_param
        })

        result = JSON.parse(response).dig('features', 0, 'attributes')
        "#{result['PATH'].to_s.rjust(3, '0')}#{result['ROW'].to_s.rjust(3, '0')}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aqila-mapas-0.4.12 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.11 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.9 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.8 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.7 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.6 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.5 lib/satellite/landsat8/coordinate_converter_service.rb
aqila-mapas-0.4.4 lib/satellite/landsat8/coordinate_converter_service.rb