module ADIWG::Mdtranslator::Readers::Fgdc::MapGridSystem

Public Class Methods

unpack(xMapGrid, hResponseObj) click to toggle source
# File lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapGridSystem.rb, line 22
def self.unpack(xMapGrid, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   hProjection = intMetadataClass.newProjection
   hGridSystemId = intMetadataClass.newIdentifier
   hProjectionId = intMetadataClass.newIdentifier
   hProjection[:gridIdentifier] = hGridSystemId
   hProjection[:projectionIdentifier] = hProjectionId

   # grid system 4.1.2.2.1 (gridsysn) - grid coordinate system name (required)
   # -> ReferenceSystemParameters.projection.projectionIdentifier.identifier
   gridName = xMapGrid.xpath('./gridsysn').text
   unless gridName.empty?
      hGridSystemId[:name] = gridName
   end
   if gridName.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: grid system name is missing'
   end

   # grid system 4.1.2.2.2 (utm) - universal transverse mercator
   xUTM = xMapGrid.xpath('./utm')
   unless xUTM.empty?
      return MapGridUtm.unpack(xUTM, hProjection, hResponseObj)
   end

   # grid system 4.1.2.2.3 (ups) - universal polar stereographic
   xUPS = xMapGrid.xpath('./ups')
   unless xUPS.empty?
      return MapGridUps.unpack(xUPS, hProjection, hResponseObj)
   end

   # grid system 4.1.2.2.4 (spcs) - state plane coordinate system
   xStateP = xMapGrid.xpath('./spcs')
   unless xStateP.empty?
      return MapGridStatePlane.unpack(xStateP, hProjection, hResponseObj)
   end

   # grid system 4.1.2.2.5 (arcsys) - equal arc-second coordinate system
   xArc = xMapGrid.xpath('./arcsys')
   unless xArc.empty?
      return MapGridEqualArcSecond.unpack(xArc, hProjection, hResponseObj)
   end

   # grid system 4.1.2.2.6 (othergrd) - other coordinate system {text}
   # -> ReferenceSystemParameters.projection.gridIdentifier.description
   otherG = xMapGrid.xpath('./othergrd').text
   unless otherG.empty?
      return MapGridOther.unpack(otherG, hProjection)
   end

   # error message
   hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: grid system is missing'

   return hProjection

end