Class: Dor::GeoMetadataDS
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::GeoMetadataDS
- Defined in:
- lib/dor/datastreams/geo_metadata_ds.rb
Overview
GeoMetadataDS is a Fedora datastream for geographic metadata. It uses the ISO 19139 metadata standard schema - a metadata standard for Geographic Information The datastream is packaged using RDF to identify the optional ISO 19139 feature catalog
Constant Summary collapse
- NS =
namespaces
{ rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', gco: 'http://www.isotc211.org/2005/gco', gmd: 'http://www.isotc211.org/2005/gmd', gfc: 'http://www.isotc211.org/2005/gfc' }.freeze
- XMLNS =
hash with all namespaces
Hash[NS.map { |k, v| ["xmlns:#{k}", v]
- NS_XSD =
schema locations
NS.keys.collect { |k| "#{NS[k]} #{NS[k]}/#{k}.xsd" }
Class Method Summary collapse
-
.xml_template ⇒ Nokogiri::XML::Document
Contains skeleton geoMetadata XML Add your druid as the suffix to rdf:about attributes.
Instance Method Summary collapse
-
#feature_catalogue ⇒ Nokogiri::XML::Document
With gfc:FC_FeatureCatalogue as root node, or nil if not provided.
-
#metadata ⇒ Nokogiri::XML::Document
With gmd:MD_Metadata as root node.
-
#prefix ⇒ Object
maintain AF < 8 indexing behavior.
-
#to_bbox ⇒ Struct
In minX minY maxX maxY order with .w, .e, .n., .s for west, east, north, south as floats.
Class Method Details
.xml_template ⇒ Nokogiri::XML::Document
Returns Contains skeleton geoMetadata XML Add your druid as the suffix to rdf:about attributes. Includes all possible xmlns for gmd and gfc.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dor/datastreams/geo_metadata_ds.rb', line 50 def self.xml_template Nokogiri::XML::Builder.new do |xml| xml['rdf'].RDF XMLNS, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => NS_XSD.join(' ') do xml['rdf'].Description 'rdf:about' => nil do xml['gmd'].MD_Metadata end xml['rdf'].Description 'rdf:about' => nil do xml['gfc'].FC_FeatureCatalogue end end end.doc end |
Instance Method Details
#feature_catalogue ⇒ Nokogiri::XML::Document
Returns with gfc:FC_FeatureCatalogue as root node, or nil if not provided.
40 41 42 43 44 45 |
# File 'lib/dor/datastreams/geo_metadata_ds.rb', line 40 def feature_catalogue root = ng_xml.xpath('/rdf:RDF/rdf:Description/gfc:FC_FeatureCatalogue', XMLNS) return nil if root.nil? || root.empty? # Feature catalog is optional Nokogiri::XML(root.first.to_xml) end |
#metadata ⇒ Nokogiri::XML::Document
Returns with gmd:MD_Metadata as root node.
29 30 31 32 33 34 35 36 |
# File 'lib/dor/datastreams/geo_metadata_ds.rb', line 29 def root = ng_xml.xpath('/rdf:RDF/rdf:Description/gmd:MD_Metadata', XMLNS) if root.nil? || root.empty? raise Dor::ParameterError, "Invalid geoMetadata -- missing MD_Metadata: #{root}" else Nokogiri::XML(root.first.to_xml) end end |
#prefix ⇒ Object
maintain AF < 8 indexing behavior
79 80 81 |
# File 'lib/dor/datastreams/geo_metadata_ds.rb', line 79 def prefix '' end |
#to_bbox ⇒ Struct
Returns in minX minY maxX maxY order with .w, .e, .n., .s for west, east, north, south as floats.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dor/datastreams/geo_metadata_ds.rb', line 67 def to_bbox params = { 'xmlns:gmd' => NS[:gmd], 'xmlns:gco' => NS[:gco] } bb = .xpath('//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox', params).first Struct.new(:w, :e, :n, :s).new( bb.xpath('gmd:westBoundLongitude/gco:Decimal', params).text.to_f, bb.xpath('gmd:eastBoundLongitude/gco:Decimal', params).text.to_f, bb.xpath('gmd:northBoundLatitude/gco:Decimal', params).text.to_f, bb.xpath('gmd:southBoundLatitude/gco:Decimal', params).text.to_f ) end |