finish spatial properties

This commit is contained in:
John Bintz 2011-03-16 17:09:49 -04:00
parent 1e3080ddc7
commit 58aa391459
2 changed files with 46 additions and 17 deletions

View File

@ -84,6 +84,7 @@ module AVM
] ]
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS) AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
AVM_SINGLES_FOR_MESSAGES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_MESSAGES)
AVM_TO_FLOAT = [ AVM_TO_FLOAT = [
:spatial_rotation, :spatial_rotation,
@ -133,9 +134,17 @@ module AVM
refs[:photoshop].add_child(%{<photoshop:Headline>#{headline}</photoshop:Headline>}) refs[:photoshop].add_child(%{<photoshop:Headline>#{headline}</photoshop:Headline>})
AVM_SINGLE_FIELDS.zip(AVM_SINGLE_MESSAGES).each do |tag, message| AVM_SINGLES_FOR_MESSAGES.each do |tag, message|
value = send(message) if value = send(message)
refs[:avm].add_child(%{<avm:#{tag}>#{value.to_s}</avm:#{tag}>}) if value case value
when Array
value = '<rdf:Seq>' + value.collect { |v| "<rdf:li>#{v.to_s}</rdf:li>" }.join + '</rdf:Seq>'
else
value = value.to_s
end
refs[:avm].add_child(%{<avm:#{tag}>#{value}</avm:#{tag}>})
end
end end
distance_nodes = [] distance_nodes = []

View File

@ -34,8 +34,6 @@ describe AVM::Image do
let(:fits_header) { 'FITS header' } let(:fits_header) { 'FITS header' }
let(:spatial_cd_matrix) { [ 1, 2, 3, 4 ] } let(:spatial_cd_matrix) { [ 1, 2, 3, 4 ] }
it "should have spatial information"
def self.with_all_options def self.with_all_options
let(:options) { { let(:options) { {
:title => title, :title => title,
@ -172,19 +170,41 @@ describe AVM::Image do
context 'with basics' do context 'with basics' do
with_all_options with_all_options
it "should have the image info tags" do def xpath_text(which, xpath)
dublin_core.at_xpath('./dc:title/rdf:Alt/rdf:li').text.should == title which.at_xpath(xpath).text
photoshop.at_xpath('./photoshop:Headline').text.should == headline end
dublin_core.at_xpath('./dc:description/rdf:Alt/rdf:li').text.should == description
avm.at_xpath('./avm:Distance.Notes').text.should == distance_notes def xpath_list(which, xpath)
avm.at_xpath('./avm:Spectral.Notes').text.should == spectral_notes which.at_xpath(xpath).search('.//rdf:li').collect(&:text)
avm.at_xpath('./avm:ReferenceURL').text.should == reference_url end
avm.at_xpath('./avm:Credit').text.should == credit
avm.at_xpath('./avm:Date').text.should == date it "should have the image info tags" do
avm.at_xpath('./avm:ID').text.should == id xpath_text(dublin_core, './dc:title/rdf:Alt/rdf:li').should == title
avm.at_xpath('./avm:Type').text.should == type xpath_text(photoshop, './photoshop:Headline').should == headline
avm.at_xpath('./avm:Image.ProductQuality').text.should == image_quality xpath_text(dublin_core, './dc:description/rdf:Alt/rdf:li').should == description
xpath_text(avm, './avm:Distance.Notes').should == distance_notes
xpath_text(avm, './avm:Spectral.Notes').should == spectral_notes
xpath_text(avm, './avm:ReferenceURL').should == reference_url
xpath_text(avm, './avm:Credit').should == credit
xpath_text(avm, './avm:Date').should == date
xpath_text(avm, './avm:ID').should == id
xpath_text(avm, './avm:Type').should == type
xpath_text(avm, './avm:Image.ProductQuality').should == image_quality
end
it "should have the spatial tags" do
xpath_text(avm, './avm:Spatial.CoordinateFrame').should == coordinate_frame
xpath_text(avm, './avm:Spatial.Equinox').should == equinox
xpath_list(avm, './avm:Spatial.ReferenceValue').should == reference_value.collect(&:to_s)
xpath_list(avm, './avm:Spatial.ReferenceDimension').should == reference_dimension.collect(&:to_s)
xpath_list(avm, './avm:Spatial.ReferencePixel').should == reference_pixel.collect(&:to_s)
xpath_list(avm, './avm:Spatial.Scale').should == spatial_scale.collect(&:to_s)
xpath_text(avm, './avm:Spatial.CoordsystemProjection').should == coordinate_system_projection
xpath_text(avm, './avm:Spatial.Quality').should == spatial_quality
xpath_text(avm, './avm:Spatial.Notes').should == spatial_notes
xpath_text(avm, './avm:Spatial.FITSheader').should == fits_header
xpath_list(avm, './avm:Spatial.CDMatrix').should == spatial_cd_matrix.collect(&:to_s)
end end
context "distance" do context "distance" do