class ADIWG::Mdtranslator::Writers::Iso19115_2::CoverageDescription
Public Class Methods
new(xml, hResponseObj)
click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_coverageDescription.rb, line 21 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2 end
Public Instance Methods
writeXML(hCoverage)
click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_coverageDescription.rb, line 27 def writeXML(hCoverage) # classes used codelistClass = MD_Codelist.new(@xml, @hResponseObj) attributeClass = Attribute.new(@xml, @hResponseObj) imageClass = MI_ImageDescription.new(@xml, @hResponseObj) # determine type of MD_CoverageDescription to write if hCoverage[:imageDescription].empty? contentTag = 'gmi:MI_CoverageDescription' else contentTag = 'gmi:MI_ImageDescription' end @xml.tag!(contentTag) do # coverage description - attribute description (required) # combine coverageName and coverageDescription attDesc = '' unless hCoverage[:coverageName].nil? attDesc += hCoverage[:coverageName] + '; ' end unless hCoverage[:coverageDescription].nil? attDesc += hCoverage[:coverageDescription] end unless attDesc == '' @xml.tag!('gmd:attributeDescription') do @xml.tag!('gco:RecordType', attDesc) end end if attDesc == '' @NameSpace.issueWarning(40, 'gmd:attributeDescription') end # coverage description - content type (required) {MD_CoverageContentTypeCode} # coverageContentTypeCode (ISO) = attributeContentType (mdJson) # in ISO 19115-1 coverageContentTypeCode [] (required) in attributeGroup # ... coverageContentTypeCode applies only to attributeGroup # in ISO 19115-2 coverageContentTypeCode (required) in CoverageDescription # ... contentInfo must be either coverageDescription or imageDescription # ... coverageContentTypeCode applies to both imageDescription and attribute (rangeDimension) # mdJson does not require either attributeGroup or imageDescription # so, coverageContentTypeCode will be missing when content info is imageDescription # how to handle in ISO 19115-2 ... # when content info is imageDescription set contentCoverageType to 'image' # when content info is attributeGroup contentCoverageType will be available # when content info is not provided set contentType to 'nilReason=missing' contentType = nil contentType = 'image' if contentTag == 'gmi:MI_ImageDescription' if contentTag == 'gmi:MI_CoverageDescription' aGroups = hCoverage[:attributeGroups] unless aGroups.empty? aAttContents = aGroups[0][:attributeContentTypes] unless aAttContents.empty? contentType = aAttContents[0] end end end unless contentType.nil? @xml.tag!('gmd:contentType') do codelistClass.writeXML('gmd', 'iso_coverageContentType', contentType) end end if contentType.nil? @NameSpace.issueWarning(41, 'gmd:contentType') end # coverage description - dimension [] haveAttribute = false if contentTag == 'gmi:MI_CoverageDescription' aGroups.each do |hGroup| aAttributes = hGroup[:attributes] aAttributes.each do |hAttribute| @xml.tag!('gmd:dimension') do attributeClass.writeXML(hAttribute) haveAttribute = true end end end if !haveAttribute && @hResponseObj[:writerShowTags] @xml.tag!('gmd:dimension') end end # coverage description - image information if contentTag == 'gmi:MI_ImageDescription' hImage = hCoverage[:imageDescription] unless hImage.empty? imageClass.writeXML(hCoverage) end end end # MI_CoverageDescription/MI_ImageDescription tag end