Class: Kibuvits_krl171bt4_coords
- Inherits:
-
Object
- Object
- Kibuvits_krl171bt4_coords
- Includes:
- Singleton
- Defined in:
- lib/kibuvits_ruby_library_krl171bt4_.rb
Overview
The class Kibuvits_krl171bt4_coords is a namespace for coordinate conversion/calculation related code.
Class Method Summary collapse
-
.i_i_scale_rectangle(i_initial_width, i_initial_height, i_new_edge_length, b_scale_by_width) ⇒ Object
i_i_scale_rectangle.
- .x_latitude_and_longitude_2_world_map_x_y_t1(fd_latitude, fd_longitude, i_world_map_width, i_world_map_height) ⇒ Object
Instance Method Summary collapse
-
#i_i_scale_rectangle(i_initial_width, i_initial_height, i_new_edge_length, b_scale_by_width) ⇒ Object
———————————————————————-.
-
#initialize ⇒ Kibuvits_krl171bt4_coords
constructor
A new instance of Kibuvits_krl171bt4_coords.
-
#x_latitude_and_longitude_2_world_map_x_y_t1(fd_latitude, fd_longitude, i_world_map_width, i_world_map_height) ⇒ Object
The material at the following address was really helpful: geographyworldonline.com/tutorial/instructions.html.
Constructor Details
#initialize ⇒ Kibuvits_krl171bt4_coords
Returns a new instance of Kibuvits_krl171bt4_coords.
14701 14702 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 14701 def initialize end |
Class Method Details
.i_i_scale_rectangle(i_initial_width, i_initial_height, i_new_edge_length, b_scale_by_width) ⇒ Object
i_i_scale_rectangle
14840 14841 14842 14843 14844 14845 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 14840 def Kibuvits_krl171bt4_coords.i_i_scale_rectangle(i_initial_width,i_initial_height, i_new_edge_length,b_scale_by_width) i_width_out,i_height_out=Kibuvits_krl171bt4_coords.instance.i_i_scale_rectangle( i_initial_width,i_initial_height,i_new_edge_length,b_scale_by_width) return i_width_out,i_height_out end |
.x_latitude_and_longitude_2_world_map_x_y_t1(fd_latitude, fd_longitude, i_world_map_width, i_world_map_height) ⇒ Object
14768 14769 14770 14771 14772 14773 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 14768 def Kibuvits_krl171bt4_coords.x_latitude_and_longitude_2_world_map_x_y_t1( fd_latitude,fd_longitude,i_world_map_width,i_world_map_height) i_x,i_y=Kibuvits_krl171bt4_coords.instance.x_latitude_and_longitude_2_world_map_x_y_t1( fd_latitude,fd_longitude,i_world_map_width,i_world_map_height) return i_x,i_y end |
Instance Method Details
#i_i_scale_rectangle(i_initial_width, i_initial_height, i_new_edge_length, b_scale_by_width) ⇒ Object
14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 14777 def i_i_scale_rectangle(i_initial_width,i_initial_height, i_new_edge_length,b_scale_by_width) bn=binding() if KIBUVITS_krl171bt4_b_DEBUG kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_initial_width kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_initial_height kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_new_edge_length kibuvits_krl171bt4_typecheck bn, [TrueClass,FalseClass], b_scale_by_width end # if kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn, 1,[i_initial_width,i_initial_height,i_new_edge_length], "\nGUID=='900a983a-b973-4e74-b468-c13290a118e7'\n") i_width_out=i_initial_width i_height_out=i_initial_height if b_scale_by_width if i_initial_width==i_new_edge_length return i_width_out,i_height_out end # if else if i_initial_height==i_new_edge_length return i_width_out,i_height_out end # if end # if # To keep the calculations that take place after the # call to this function more effective, the output of # this function is partly enforced to be in Fixnum format. fd_width_0=nil fd_height_0=nil fd_width_1=nil fd_height_1=nil fd_len_new=nil fd_ref=640000.0 b_use_Float=false if (i_initial_width<fd_ref)&&(i_initial_height<fd_ref)&&(i_new_edge_length<fd_ref) fd_width_0=i_initial_width.to_f fd_height_0=i_initial_height.to_f fd_len_new=i_new_edge_length.to_f b_use_Float=true else fd_width_0=i_initial_width.to_r fd_height_0=i_initial_height.to_r fd_len_new=i_new_edge_length.to_r end # if if b_scale_by_width fd_new_dev_old=fd_len_new/fd_width_0 fd_width_1=fd_len_new fd_height_1=fd_height_0*fd_new_dev_old else fd_new_dev_old=fd_len_new/fd_height_0 fd_width_1=fd_width_0*fd_new_dev_old fd_height_1=fd_len_new end # if i_width_out=fd_width_1.round.to_i i_height_out=fd_height_1.round.to_i i_width_out=1 if i_width_out==0 i_height_out=1 if i_height_out==0 return i_width_out,i_height_out end |
#x_latitude_and_longitude_2_world_map_x_y_t1(fd_latitude, fd_longitude, i_world_map_width, i_world_map_height) ⇒ Object
The material at the following address was really helpful: geographyworldonline.com/tutorial/instructions.html
This function returns 2 whole numbers, i_x, i_y, where 0<=i_x<=(i_world_map_width-1) 0<=i_y<=(i_world_map_height-1)
14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 14710 def x_latitude_and_longitude_2_world_map_x_y_t1(fd_latitude,fd_longitude, i_world_map_width,i_world_map_height) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_typecheck bn, [Fixnum,Rational,Float,Bignum], fd_latitude kibuvits_krl171bt4_typecheck bn, [Fixnum,Rational,Float,Bignum], fd_longitude kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_world_map_width kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_world_map_height end # if KIBUVITS_krl171bt4_b_DEBUG if (90<fd_latitude) msg="90< fd_latitude=="+fd_latitude.to_s kibuvits_krl171bt4_throw(msg) end # if if (180<fd_longitude) msg="180 < fd_longitude=="+fd_longitude.to_s kibuvits_krl171bt4_throw(msg) end # if if (fd_latitude<(-90)) msg="fd_latitude=="+fd_latitude.to_s+" < (-90) " kibuvits_krl171bt4_throw(msg) end # if if (fd_longitude<(-180)) msg="fd_longitude=="+fd_longitude.to_s+" < (-180) " kibuvits_krl171bt4_throw(msg) end # if if (i_world_map_width<1) msg="i_world_map_width=="+i_world_map_width.to_s+" < 1 " kibuvits_krl171bt4_throw(msg) end # if if (i_world_map_height<1) msg="i_world_map_height=="+i_world_map_height.to_s+" < 1 " kibuvits_krl171bt4_throw(msg) end # if fd_lat=fd_latitude.to_r # North-wards, [-90,90] fd_long=fd_longitude.to_r # East-wards [-180,180] # The North pole and "East pole" (from England) are with # positive values. The general idea of the calculations: # http://urls.softf1.com/a1/krl/frag2/ fd_r=(i_world_map_height*1.0)/2 fd_sin_alpha=Math.sin(fd_lat) #fd_cos_alpha=Math.cos(fd_lat) #fd_r2=fd_r*fd_cos_alpha fd_h2=fd_r*fd_sin_alpha i_y=(fd_r-fd_h2).to_f.round(0) fd_w2=(i_world_map_width*1.0)/2 fd_2=fd_long/180.0 i_x=(fd_w2+(fd_2*fd_w2)).to_f.round(0) i_x=i_world_map_width-1 if (i_world_map_width-1)<i_x i_y=i_world_map_height-1 if (i_world_map_height-1)<i_y i_x=0 if i_x<0 i_y=0 if i_y<0 return i_x,i_y end |