class RGeoServer::Coverage

A coverage is a raster based data set which originates from a coverage store.

Constants

OBJ_ATTRIBUTES
OBJ_DEFAULT_ATTRIBUTES

Public Class Methods

member_xpath() click to toggle source
# File lib/rgeoserver/coverage.rb, line 48
def self.member_xpath
  "//#{resource_name}"
end
new(catalog, options) click to toggle source

@param [RGeoServer::Catalog] catalog @param [Hash] options

Calls superclass method
# File lib/rgeoserver/coverage.rb, line 96
def initialize catalog, options 
  super(catalog)
  _run_initialize_callbacks do
    workspace = options[:workspace] || 'default'
    if workspace.instance_of? String
      @workspace = @catalog.get_workspace(workspace)
    elsif workspace.instance_of? Workspace
      @workspace = workspace
    else
      raise "Not a valid workspace"
    end
    coverage_store = options[:coverage_store]
    if coverage_store.instance_of? String
      @coverage_store = CoverageStore.new @catalog, :workspace => @workspace, :name => coverage_store
    elsif coverage_store.instance_of? CoverageStore
      @coverage_store = coverage_store
    else
      raise "Not a valid coverage store"
    end

    @name = options[:name]
    @enabled = options[:enabled] || true
    @route = route
  end
end
resource_name() click to toggle source
# File lib/rgeoserver/coverage.rb, line 52
def self.resource_name
  @@resource_name
end
root() click to toggle source
# File lib/rgeoserver/coverage.rb, line 44
def self.root
  @@root
end

Public Instance Methods

message() click to toggle source
# File lib/rgeoserver/coverage.rb, line 65
def message
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.coverage {
      xml.nativeName @name if new? # on new only
      xml.name @name
      xml.title @title if title_changed? || new?
      xml.abstract @abstract if abstract_changed? || new?
      xml.enabled @enabled
      xml.metadataLinks {
        @metadata_links.each do |m|
          raise ArgumentError, "Malformed metadata_links" unless m.is_a? Hash
          xml.metadataLink {
            xml.type_ to_mimetype(m['metadataType'])
            xml.metadataType m['metadataType']
            xml.content m['content']
          }
        end
      } unless @metadata_links.empty?
      xml.keywords {
        @keywords.each do |k|
          xml.keyword RGeoServer::Metadata::to_keyword(k)
        end
      } if @keywords and new? or keywords_changed?
      
    }
  end
  @message = builder.doc.to_xml 
end
profile_xml_to_hash(profile_xml) click to toggle source

@return [Hash] extraction from GeoServer XML for this coverage

# File lib/rgeoserver/coverage.rb, line 123
def profile_xml_to_hash profile_xml
  doc = profile_xml_to_ng profile_xml
  h = {
    "coverage_store" => @coverage_store.name,
    "workspace" => @workspace.name,
    "name" => doc.at_xpath('//name').text.strip,
    "nativeName" => doc.at_xpath('//nativeName/text()').to_s,
    "nativeCRS" => doc.at_xpath('//nativeCRS/text()').to_s,
    "title" => doc.at_xpath('//title/text()').to_s,
    "srs" => doc.at_xpath('//srs/text()').to_s,
    "nativeBoundingBox" => { 
      'minx' => doc.at_xpath('//nativeBoundingBox/minx/text()').to_s,
      'miny' => doc.at_xpath('//nativeBoundingBox/miny/text()').to_s,
      'maxx' => doc.at_xpath('//nativeBoundingBox/maxx/text()').to_s,
      'maxy' => doc.at_xpath('//nativeBoundingBox/maxy/text()').to_s,
      'crs' => doc.at_xpath('//nativeBoundingBox/crs/text()').to_s
    },
    "latLonBoundingBox" => { 
      'minx' => doc.at_xpath('//latLonBoundingBox/minx/text()').to_s,
      'miny' => doc.at_xpath('//latLonBoundingBox/miny/text()').to_s,
      'maxx' => doc.at_xpath('//latLonBoundingBox/maxx/text()').to_s,
      'maxy' => doc.at_xpath('//latLonBoundingBox/maxy/text()').to_s,
      'crs' => doc.at_xpath('//latLonBoundingBox/crs/text()').to_s
    },
    "abstract" => doc.at_xpath('//abstract/text()').to_s, 
    "supportedFormats" => doc.xpath('//supportedFormats/string').collect{ |t| t.to_s },
    "keywords" => doc.at_xpath('//keywords').collect { |kl|
      {
        'keyword' => kl.at_xpath('//string/text()').to_s
      }
    },
    "metadataLinks" => doc.xpath('//metadataLinks/metadataLink').collect{ |m|
      {
        'type' => m.at_xpath('//type/text()').to_s,
        'metadataType' => m.at_xpath('//metadataType/text()').to_s,
        'content' => m.at_xpath('//content/text()').to_s
      }
    },
  }.freeze
  h  
end
route() click to toggle source
# File lib/rgeoserver/coverage.rb, line 56
def route
  @@route % [@workspace.name , @coverage_store.name]
end
to_mimetype(type, default = 'text/xml') click to toggle source
# File lib/rgeoserver/coverage.rb, line 60
def to_mimetype(type, default = 'text/xml')
  return @@metadata_types[type.upcase] if @@metadata_types.include?(type.upcase) 
  default
end