Class: PhotoscanOutputs::CameraFile

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/photoscan_outputs/camera_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cameras, global) ⇒ CameraFile

Returns a new instance of CameraFile.



12
13
14
15
# File 'lib/photoscan_outputs/camera_file.rb', line 12

def initialize( cameras, global )
  @cameras = cameras
  @global_transform = global
end

Instance Attribute Details

#camerasObject (readonly)

Returns the value of attribute cameras.



8
9
10
# File 'lib/photoscan_outputs/camera_file.rb', line 8

def cameras
  @cameras
end

#global_transformObject (readonly)

Returns the value of attribute global_transform.



8
9
10
# File 'lib/photoscan_outputs/camera_file.rb', line 8

def global_transform
  @global_transform
end

Class Method Details

.load(file) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/photoscan_outputs/camera_file.rb', line 30

def self.load( file )
  raise "Can't read file \"#{file}\"" unless File.readable? file

  xml = Ox.load File.read( file )

  cameras = xml.locate("collection/cameras").first.nodes

  global = Transform.from_xml xml.locate("collection").first.transform

  cameras.map! { |cam|
    Camera.from_xml( cam, global )
  }

  CameraFile.new( cameras, global )
end

Instance Method Details

#eachObject



21
22
23
24
25
26
27
# File 'lib/photoscan_outputs/camera_file.rb', line 21

def each
  if block_given?
    @cameras.each { |blk| yield blk }
  else
    @cameras.each
  end
end

#find_by_name(name) ⇒ Object



17
18
19
# File 'lib/photoscan_outputs/camera_file.rb', line 17

def find_by_name( name )
  find { |cam| cam.name.match  name }
end