Module: GeoConcerns::Extractors::Iso19139Helper
- Included in:
- GeoConcerns::ExternalMetadataFileBehavior
- Defined in:
- app/models/concerns/geo_concerns/extractors/iso19139_helper.rb
Constant Summary collapse
- NS =
{ 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd', 'xmlns:gco' => 'http://www.isotc211.org/2005/gco' }.freeze
Instance Method Summary collapse
-
#extract_iso19139_metadata(doc) ⇒ Object
TODO: Migrate this code into an XSLT? TODO: Need to support multivalued fields.
Instance Method Details
#extract_iso19139_metadata(doc) ⇒ Object
TODO: Migrate this code into an XSLT? TODO: Need to support multivalued fields
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/concerns/geo_concerns/extractors/iso19139_helper.rb', line 11 def (doc) h = {} doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString', NS).tap do |node| h[:title] = [node.text.strip] end doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox', NS).tap do |node| w = node.at_xpath('gmd:westBoundLongitude/gco:Decimal', NS).text.to_f e = node.at_xpath('gmd:eastBoundLongitude/gco:Decimal', NS).text.to_f n = node.at_xpath('gmd:northBoundLatitude/gco:Decimal', NS).text.to_f s = node.at_xpath('gmd:southBoundLatitude/gco:Decimal', NS).text.to_f h[:coverage] = GeoConcerns::Coverage.new(n, e, s, w).to_s end doc.at_xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString', NS).tap do |node| h[:description] = [node.text.strip] end doc.xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue=\'originator\']', NS).each do |node| h[:creator] = begin [node.at_xpath('ancestor-or-self::*/gmd:individualName', NS).text.strip] rescue [node.at_xpath('ancestor-or-self::*/gmd:organisationName', NS).text.strip] end end # TODO: Not sure if custodian is the same as source doc.xpath('//gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode[@codeListValue=\'custodian\']', NS).each do |node| h[:source] = begin [node.at_xpath('ancestor-or-self::*/gmd:individualName', NS).text.strip] rescue [node.at_xpath('ancestor-or-self::*/gmd:organisationName', NS).text.strip] end end h end |