class ADIWG::Mdtranslator::Writers::Fgdc::SpatialReference
Public Class Methods
new(xml, hResponseObj)
click to toggle source
# File lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialReference.rb, line 22 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj end
Public Instance Methods
writeXML(hResourceInfo)
click to toggle source
# File lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialReference.rb, line 27 def writeXML(hResourceInfo) aRepTypes = hResourceInfo[:spatialRepresentationTypes] aResolutions = hResourceInfo[:spatialResolutions] aSpaceRefs = hResourceInfo[:spatialReferenceSystems] # classes used geoResClass = GeographicResolution.new(@xml, @hResponseObj) planarClass = PlanarReference.new(@xml, @hResponseObj) localClass = LocalSystem.new(@xml, @hResponseObj) geodeticClass = GeodeticReference.new(@xml, @hResponseObj) vDatumClass = VerticalDatum.new(@xml, @hResponseObj) outContext = 'spatial reference' # spatial reference 4.1 (horizsys) - horizontal coordinate reference system (required) # oneOf [geograph | planar | local] @xml.tag!('horizsys') do # horizontal reference 4.1.1 (geograph) - geographic resolution # <- resourceInfo.spatialResolution[].geographicResolution (first) aResolutions.each do |hSpaceRes| unless hSpaceRes.empty? if hSpaceRes[:geographicResolution] unless hSpaceRes[:geographicResolution].empty? @xml.tag!('geograph') do geoResClass.writeXML(hSpaceRes[:geographicResolution], outContext) end break end end end end # horizontal reference 4.1.2 (planar) - planar coordinate system [] # <- spatialReferencesTypes[] # <- spatialReferences[].systemParameterSet.projection # <- spatialResolution[].coordinateResolution # <- spatialResolution[].bearingDistanceResolution havePlanar = false havePlanar = true unless aRepTypes.empty? aSpaceRefs.each do |hSpaceRef| unless hSpaceRef[:systemParameterSet].empty? unless hSpaceRef[:systemParameterSet][:projection].empty? hProjection = hSpaceRef[:systemParameterSet][:projection] unless hProjection[:projectionIdentifier][:identifier] == 'localSystem' havePlanar = true end end end end aResolutions.each do |hResolution| havePlanar = true if hResolution[:coordinateResolution] havePlanar = true if hResolution[:bearingDistanceResolution] end if havePlanar @xml.tag!('planar') do planarClass.writeXML(aSpaceRefs, aRepTypes, aResolutions, outContext) end end # horizontal reference 4.1.3 (local) - any rectangular coordinate system not aligned with surface of earth # <- spatialReferences[].systemParameterSet.projection # localSYSTEM is not the same as localPLANAR in fgdc # however the same projection parameters are used in mdJson to save info # local system sets projection = 'localSystem' # local planar sets projection = 'localPlanar' aSpaceRefs.each do |hSpaceRef| unless hSpaceRef[:systemParameterSet].empty? if hSpaceRef[:systemParameterSet][:projection] hProjection = hSpaceRef[:systemParameterSet][:projection] unless hProjection.empty? if hProjection[:projectionIdentifier][:identifier] == 'localSystem' @xml.tag!('local') do localClass.writeXML(hProjection, outContext) end end end end end end # horizontal reference 4.1.4 (geodetic) - parameters for shape of earth # <- spatialReferences[].systemParameterSet.geodetic aSpaceRefs.each do |hSpaceRef| unless hSpaceRef[:systemParameterSet].empty? if hSpaceRef[:systemParameterSet][:geodetic] hGeodetic = hSpaceRef[:systemParameterSet][:geodetic] unless hGeodetic.empty? @xml.tag!('geodetic') do geodeticClass.writeXML(hGeodetic, outContext) end end end end end end # vertical reference 4.2 (vertdef) - vertical coordinate reference system # <- spatialReferences[].systemParameterSet.verticalDatum # pass in the full spatial reference array, # ... all vertical datum must be under same 'vertdef' tag haveVertical = false aSpaceRefs.each do |hSpaceRef| unless hSpaceRef[:systemParameterSet].empty? unless hSpaceRef[:systemParameterSet][:verticalDatum].empty? haveVertical = true end end end if haveVertical @xml.tag!('vertdef') do vDatumClass.writeXML(aSpaceRefs, outContext) end end end