lib/adiwg/mdtranslator/writers/iso/classes/class_timePeriod.rb in adiwg-mdtranslator-0.10.2 vs lib/adiwg/mdtranslator/writers/iso/classes/class_timePeriod.rb in adiwg-mdtranslator-0.12.0

- old
+ new

@@ -2,53 +2,62 @@ # writer output in XML # History: # Stan Smith 2013-11-04 original script # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure +# Stan Smith 2014-12-12 refactored to handle namespacing readers and writers require 'module_dateTimeFun' -class TimePeriod +module ADIWG + module Mdtranslator + module Writers + module Iso - def initialize(xml) - @xml = xml - end + class TimePeriod - def writeXML(hTempP) + def initialize(xml) + @xml = xml + end - timeID = hTempP[:timeId] - if timeID.nil? - $idCount = $idCount.succ - timeID = 'timePeriod' + $idCount - end + def writeXML(hTempP) - @xml.tag!('gml:TimePeriod',{'gml:id'=>timeID}) do + timeID = hTempP[:timeId] + if timeID.nil? + $idCount = $idCount.succ + timeID = 'timePeriod' + $idCount + end - # time period - description - s = hTempP[:description] - if !s.nil? - @xml.tag!('gml:description',s) - elsif $showAllTags - @xml.tag!('gml:description') - end + @xml.tag!('gml:TimePeriod', {'gml:id' => timeID}) do - # time period - begin position - hDateTime = hTempP[:beginTime] - timeInstant = hDateTime[:dateTime] - timeResolution = hDateTime[:dateResolution] - dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(timeInstant,timeResolution) - @xml.tag!('gml:beginPosition',dateStr) + # time period - description + s = hTempP[:description] + if !s.nil? + @xml.tag!('gml:description', s) + elsif $showAllTags + @xml.tag!('gml:description') + end - # time period - begin position - hDateTime = hTempP[:endTime] - timeInstant = hDateTime[:dateTime] - timeResolution = hDateTime[:dateResolution] - dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(timeInstant,timeResolution) - @xml.tag!('gml:endPosition',dateStr) + # time period - begin position + hDateTime = hTempP[:beginTime] + timeInstant = hDateTime[:dateTime] + timeResolution = hDateTime[:dateResolution] + dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(timeInstant, timeResolution) + @xml.tag!('gml:beginPosition', dateStr) - end + # time period - begin position + hDateTime = hTempP[:endTime] + timeInstant = hDateTime[:dateTime] + timeResolution = hDateTime[:dateResolution] + dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(timeInstant, timeResolution) + @xml.tag!('gml:endPosition', dateStr) - end + end -end + end + end + end + end + end +end