Method: Proj::Database#celestial_bodies

Defined in:
lib/proj/database.rb

#celestial_bodies(authority = nil) ⇒ Array<CelestialBody>

Returns a list of celestial bodies from the database

Parameters:

  • authority (String) (defaults to: nil)

    Authority name, used to restrict the search. Set to nil for all authorities.

Returns:

See Also:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/proj/database.rb', line 193

def celestial_bodies(authority = nil)
  out_result_count = FFI::MemoryPointer.new(:int)
  ptr = Api.proj_get_celestial_body_list_from_database(self.context, authority, out_result_count)

  body_ptrs = ptr.read_array_of_pointer(out_result_count.read_int)
  result = body_ptrs.map do |body_ptr|
    # First read the pointer to a structure
    struct = Api::ProjCelestialBodyInfo.new(body_ptr)

    # Now map this to a Ruby Struct
    CelestialBody.new(struct[:auth_name], struct[:name])
  end

  Api.proj_celestial_body_list_destroy(ptr)

  result
end