Module: NSWTopo::WorldFile
Instance Method Summary collapse
- #geotransform(top_left, resolution, angle) ⇒ Object
- #write(top_left, resolution, angle, path) ⇒ Object
Instance Method Details
#geotransform(top_left, resolution, angle) ⇒ Object
5 6 7 8 9 |
# File 'lib/nswtopo/gis/world_file.rb', line 5 def geotransform(top_left, resolution, angle) sin, cos = Math::sin(angle * Math::PI / 180.0), Math::cos(angle * Math::PI / 180.0) [[top_left[0], resolution * cos, resolution * sin], [top_left[1], resolution * sin, -resolution * cos]] end |
#write(top_left, resolution, angle, path) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/nswtopo/gis/world_file.rb', line 11 def write(top_left, resolution, angle, path) (x, r00, r01), (y, r10, r11) = geotransform(top_left, resolution, angle) path.open("w") do |file| file.puts r00, r01, r10, r11 file.puts x + 0.5 * resolution, y - 0.5 * resolution end end |