Class: ADIWG::Mdtranslator::Writers::Fgdc::Keyword

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ Keyword

Returns a new instance of Keyword.



17
18
19
20
21
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_keyword.rb', line 17

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Fgdc
end

Instance Method Details

#writeXML(aKeywords) ⇒ Object



23
24
25
26
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
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_keyword.rb', line 23

def writeXML(aKeywords)

   # array of keyword sets
   aKeywords.each do |hKeySet|

      # find the keyword set parts
      type = hKeySet[:keywordType]
      aKeywords = hKeySet[:keywords]
      hThesaurus = hKeySet[:thesaurus]
      thesaurusName = nil
      unless hThesaurus.empty?
         thesaurusName = hThesaurus[:title]
      end

      # keyword 1.6.1 (theme) - theme keywords
      if type == 'theme' || type == 'isoTopicCategory'
         @xml.tag!('theme') do
            thesaurusName = 'ISO 19115 Topic Category' if type == 'isoTopicCategory'
            unless thesaurusName.nil?
               @xml.tag!('themekt', thesaurusName)
            end
            if thesaurusName.nil?
               @NameSpace.issueWarning(190, 'themekt', 'thematic keywords')
            end
            aKeywords.each do |hKeyword|
               keyword = hKeyword[:keyword]
               unless keyword.nil?
                  @xml.tag!('themekey', keyword)
               end
            end
         end
      end

      # keyword 1.6.2 (place) - place keywords
      if type == 'place'
         @xml.tag!('place') do
            unless thesaurusName.nil?
               @xml.tag!('placekt', thesaurusName)
            end
            if thesaurusName.nil?
               @NameSpace.issueWarning(190, 'placekt', 'place keywords')
            end
            aKeywords.each do |hKeyword|
               keyword = hKeyword[:keyword]
               unless keyword.nil?
                  @xml.tag!('placekey', keyword)
               end
            end
         end
      end

      # keyword 1.6.3 (stratum) - stratum keywords
      if type == 'stratum'
         @xml.tag!('stratum') do
            unless thesaurusName.nil?
               @xml.tag!('stratkt', thesaurusName)
            end
            if thesaurusName.nil?
               @NameSpace.issueWarning(190, 'stratkt', 'stratigraphic keywords')
            end
            aKeywords.each do |hKeyword|
               keyword = hKeyword[:keyword]
               unless keyword.nil?
                  @xml.tag!('stratkey', keyword)
               end
            end
         end
      end

      # keyword 1.6.4 (temporal) - temporal keywords
      if type == 'temporal'
         @xml.tag!('temporal') do
            unless thesaurusName.nil?
               @xml.tag!('tempkt', thesaurusName)
            end
            if thesaurusName.nil?
               @NameSpace.issueWarning(190, 'tempkt', 'temporal keywords')
            end
            aKeywords.each do |hKeyword|
               keyword = hKeyword[:keyword]
               unless keyword.nil?
                  @xml.tag!('tempkey', keyword)
               end
            end
         end
      end

      # other keywordType(s) not transferred to FGDC

   end

end