Initial MoonModel implementation

This commit is contained in:
Nick Estes
2026-08-11 14:41:33 -07:00
commit 518fe64b13
36 changed files with 2587 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# frozen_string_literal: true
require "minitest/autorun"
require "tmpdir"
require "zip"
require "moon_model"
module TestData
def make_data(path, width: 16, height: 8)
elevations = Array.new(width * height) { |i| ((i % width) - width / 2) * 20 }
reflectance = Array.new(width * height) { |i| (255.0 * (i % width) / (width - 1)).round }
header = { "format_version" => 1, "title" => "test data", "width" => width, "height" => height,
"elevation_offset_range_m" => elevations.minmax }
encoded = JSON.generate(header)
Zlib::GzipWriter.open(path) do |gzip|
gzip.write(MoonModel::DataSet::MAGIC)
gzip.write([encoded.bytesize].pack("L<"))
gzip.write(encoded)
gzip.write(elevations.pack("s<*"))
gzip.write(reflectance.pack("C*"))
end
path
end
end
class Minitest::Test
include TestData
end