class ADIWG::Mdtranslator::Writers::Iso19115_1::GeographicExtent

Public Class Methods

new(xml, hResponseObj) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geographicExtent.rb, line 18
def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
end

Public Instance Methods

writeXML(hGeoExtent) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geographicExtent.rb, line 23
def writeXML(hGeoExtent)

   # classes used
   bBoxClass = EX_GeographicBoundingBox.new(@xml, @hResponseObj)
   idClass = MD_Identifier.new(@xml, @hResponseObj)
   geoEleClass = GeographicElement.new(@xml, @hResponseObj)

   extType = hGeoExtent[:containsData]

   # geographic element - geographic bounding box
   # test for user provided bounding box
   # if empty, use computedBbox
   hBbox = hGeoExtent[:boundingBox]
   if hBbox.empty?
      hBbox = hGeoExtent[:computedBbox]
   end
   unless hBbox.empty?
      @xml.tag!('gex:geographicElement') do
         @xml.tag!('gex:EX_GeographicBoundingBox') do

            # geographic bounding box - extent type {Boolean}
            @xml.tag!('gex:extentTypeCode') do
               @xml.tag!('gco:Boolean', extType)
            end

            # geographic bounding box - bounding box
            bBoxClass.writeXML(hBbox)
         end
      end
   end

   # geographic element - geographic description
   unless hGeoExtent[:identifier].empty?
      @xml.tag!('gex:geographicElement') do
         @xml.tag!('gex:EX_GeographicDescription') do

            # geographic description - extent type {Boolean}
            @xml.tag!('gex:extentTypeCode') do
               @xml.tag!('gco:Boolean', extType)
            end

            # geographic description - geographic identifier {MD_Identifier}
            @xml.tag!('gex:geographicIdentifier') do
               idClass.writeXML(hGeoExtent[:identifier], 'geographic extent')
            end

         end
      end
   end

   # geographic element - geographic bounding polygon
   unless hGeoExtent[:geographicElements].empty?
      @xml.tag!('gex:geographicElement') do
         @xml.tag!('gex:EX_BoundingPolygon') do

            # bounding polygon - extent type {Boolean}
            @xml.tag!('gex:extentTypeCode') do
               @xml.tag!('gco:Boolean', extType)
            end

            # bounding polygon - geographic elements {GeoJSON}
            geoEleClass.writeXML(hGeoExtent[:geographicElements])

         end
      end
   end

end