Class: ADIWG::Mdtranslator::Writers::Iso19115_2::CoverageDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_coverageDescription.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ CoverageDescription



21
22
23
24
25
# 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

Instance Method Details

#writeXML(hCoverage) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# 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?
       = 'gmi:MI_CoverageDescription'
   else
       = 'gmi:MI_ImageDescription'
   end

   @xml.tag!() 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  == 'gmi:MI_ImageDescription'
      if  == '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  == '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  == 'gmi:MI_ImageDescription'
         hImage = hCoverage[:imageDescription]
         unless hImage.empty?
            imageClass.writeXML(hCoverage)
         end
      end

   end # MI_CoverageDescription/MI_ImageDescription tag
end