Class: Iso191152Writer
- Inherits:
-
Object
- Object
- Iso191152Writer
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb
Instance Method Summary collapse
- #extentFromGeoElement(hGeoElement, geoType) ⇒ Object
-
#initialize ⇒ Iso191152Writer
constructor
A new instance of Iso191152Writer.
- #prescanGeoElements(internalObj) ⇒ Object
- #writeXML(internalObj) ⇒ Object
Constructor Details
#initialize ⇒ Iso191152Writer
Returns a new instance of Iso191152Writer.
18 19 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb', line 18 def initialize end |
Instance Method Details
#extentFromGeoElement(hGeoElement, geoType) ⇒ Object
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb', line 89 def extentFromGeoElement(hGeoElement, geoType) # build new extent to portray supplemental information # from elementGeometry if !hGeoElement[:temporalElements].empty? || !hGeoElement[:verticalElements].empty? || !hGeoElement[:elementIdentifiers].empty? # get unique id for geometry # if geometry id was missing, set it at this time so # ... it will match the supplemental information extent description geoID = hGeoElement[:elementId] if geoID.nil? $idCount = $idCount.succ geoID = geoType + $idCount hGeoElement[:elementId] = geoID end # build unique id for extent geometry $idCount = $idCount.succ extGeoID = geoType + $idCount intMetadataClass = InternalMetadata.new intExtent = intMetadataClass.newExtent intGeoEle = intMetadataClass.newGeoElement intGeoEle[:elementId] = extGeoID intGeoEle[:elementGeometry] = hGeoElement[:elementGeometry] intExtent[:extDesc] = 'Supplemental information for ' + geoID intExtent[:extGeoElements] << intGeoEle intExtent[:extIdElements] = hGeoElement[:elementIdentifiers] intExtent[:extTempElements] = hGeoElement[:temporalElements] intExtent[:extVertElements] = hGeoElement[:verticalElements] return intExtent else return nil end end |
#prescanGeoElements(internalObj) ⇒ Object
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 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb', line 36 def prescanGeoElements(internalObj) # supplemental information for the geographic element is carried in the # ... internal structure in the temporalElements:, verticalElements:, # ... and elementIdentifiers: attributes of the extGeoElements: # ... of the extent. # since temporal, vertical, and identify information in ISO is a property # ... of EX_Extent and not of the geographicElement, # ... this code creates a new extent for each geographicElement # ... that has supplemental information and # ... moves the supplemental information from the geometry to the new extent. # In this implementation, supplemental information is only allowed for # ... geometry types of Point, LineString, and Polygon aExtents = internalObj[:metadata][:resourceInfo][:extents] unless aExtents.empty? aExtents.each do |hExtent| aGeoElements = hExtent[:extGeoElements] unless aGeoElements.empty? aGeoElements.each do |hGeoElement| hGeometry = hGeoElement[:elementGeometry] unless hGeometry.empty? geoType = hGeometry[:geoType] case geoType when 'Point', 'LineString', 'Polygon' newExtent = extentFromGeoElement(hGeoElement, geoType) if !newExtent.nil? aExtents << newExtent end when 'MultiGeometry' aGeoMembers = hGeometry[:geometry] unless aGeoMembers.empty? aGeoMembers.each do |hGeoMemberElement| hGeometry = hGeoMemberElement[:elementGeometry] unless hGeometry.empty? geoType = hGeometry[:geoType] case geoType when 'Point', 'LineString', 'Polygon' newExtent = extentFromGeoElement(hGeoMemberElement, geoType) if !newExtent.nil? aExtents << newExtent end end end end end end end end end end end end |
#writeXML(internalObj) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb', line 21 def writeXML(internalObj) # pre-scan the internal object to create a new extents for each geometry # ... that has supplemental information (temporal, vertical, identity) # ... new extents will be added to internalObj as needed prescanGeoElements(internalObj) # create new XML document xml = Builder::XmlMarkup.new(indent: 3) = MI_Metadata.new(xml) = .writeXML(internalObj) return end |