Sha256: b00bb64c0bbe20fb8f108919d129b7e6b138766b065e7e46967f22fc03504161

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Smappy::Location do
  let(:location) { Smappy::Location.new(50.9985099, 5.857652) }
  
  describe '#to_tile' do
    it 'returns a tile at the default zoomlevel' do
      tile = location.to_tile
      tile.zoomlevel.should == 0
    end
    
    it 'returns a tile at the specified zoomlevel' do
      tile = location.to_tile zoomlevel: 15
      tile.zoomlevel.should == 15
    end
    
    it 'returns a tile with the correct position at the specified zoomlevel' do
      tile = location.to_tile zoomlevel: 15
      [tile.x, tile.y].should == [16917, 10970]
    end
  end
  
  describe '#position_on_map' do
    it 'returns the coordinates of the position on the given map' do
      map = Smappy::StaticMap.new(center: [50.9985099, 5.857652], zoomlevel: 15)
      position = location.position_on_map(map)
      position.should == [250, 175]
    end
  end
  
  describe '#position_on_tile' do
    it 'returns the coordinates of the position of the location within the given tile' do
      tile     = location.to_tile zoomlevel: 15
      position = location.position_on_tile tile
      position.should == [45, 52]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smappy-0.0.4 spec/smappy/location_spec.rb
smappy-0.0.3 spec/smappy/location_spec.rb
smappy-0.0.2 spec/smappy/location_spec.rb