Class: ADIWG::Mdtranslator::Writers::Iso19115_2::TimePeriod
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Iso19115_2::TimePeriod
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb
Instance Method Summary collapse
-
#initialize(xml, hResponseObj) ⇒ TimePeriod
constructor
A new instance of TimePeriod.
- #writeXML(hPeriod) ⇒ Object
Constructor Details
#initialize(xml, hResponseObj) ⇒ TimePeriod
Returns a new instance of TimePeriod.
22 23 24 25 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb', line 22 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj end |
Instance Method Details
#writeXML(hPeriod) ⇒ 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 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb', line 27 def writeXML(hPeriod) # classes used gmlClass = GMLIdentifier.new(@xml, @hResponseObj) # TimePeriod must have a uniqueID timeID = hPeriod[:timeId] if timeID.nil? @hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ timeID = 'timePeriod' + @hResponseObj[:writerMissingIdCount] else timeID.gsub!(/[^0-9a-zA-Z]/, '') end @xml.tag!('gml:TimePeriod', {'gml:id' => timeID}) do # time period - description s = hPeriod[:description] unless s.nil? @xml.tag!('gml:description', s) end if s.nil? && @hResponseObj[:writerShowTags] @xml.tag!('gml:description') end # time period - identifier {gmlIdentifier} hGMLid = hPeriod[:identifier] unless hGMLid.empty? gmlClass.writeXML(hGMLid) end if hGMLid.empty? && @hResponseObj[:writerShowTags] @xml.tag!('gml:identifier', {'codeSpace' => ''}) end # time period - names [] aNames = hPeriod[:periodNames] aNames.each do |name| @xml.tag!('gml:name', name) end if aNames.empty? && @hResponseObj[:writerShowTags] @xml.tag!('gml:name') end # time period - begin position # tag always required, however value may be empty # if empty add indeterminatePosition="unknown" unless hPeriod[:startDateTime].empty? hDateTime = hPeriod[:startDateTime] dateTime = hDateTime[:dateTime] timeResolution = hDateTime[:dateResolution] dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(dateTime, timeResolution) @xml.tag!('gml:beginPosition', dateStr) end if hPeriod[:startDateTime].empty? @xml.tag!('gml:beginPosition', {indeterminatePosition: 'unknown'}) end # time period - begin position # tag always required, however value may be empty # if empty add indeterminatePosition="unknown" unless hPeriod[:endDateTime].empty? hDateTime = hPeriod[:endDateTime] dateTime = hDateTime[:dateTime] timeResolution = hDateTime[:dateResolution] dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(dateTime, timeResolution) @xml.tag!('gml:endPosition', dateStr) end if hPeriod[:endDateTime].empty? @xml.tag!('gml:endPosition', {indeterminatePosition: 'unknown'}) end # time period - time interval hInterval = hPeriod[:timeInterval] unless hInterval.empty? units = hInterval[:units] interval = hInterval[:interval] @xml.tag!('gml:timeInterval', {'unit' => units}, interval) end # time period - duration (do not output if have time interval) hDuration = hPeriod[:duration] if hInterval.empty? && !hDuration.empty? duration = AdiwgDateTimeFun.writeDuration(hDuration) @xml.tag!('gml:duration', duration) end end # TimePeriod tag end |