lib/rgeoserver/coverage.rb in rgeoserver-0.5.6 vs lib/rgeoserver/coverage.rb in rgeoserver-0.5.7

- old
+ new

@@ -1,12 +1,12 @@ module RGeoServer # A coverage is a raster based data set which originates from a coverage store. class Coverage < ResourceInfo - OBJ_ATTRIBUTES = {:catalog => "catalog", :workspace => "workspace", :coverage_store => "coverage_store", :name => "name", :title => "title" } - OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :coverage_store => nil, :name => nil, :title => nil } + OBJ_ATTRIBUTES = {:catalog => "catalog", :workspace => "workspace", :coverage_store => "coverage_store", :name => "name", :title => "title", :abstract => "abstract", :metadata_links => "metadataLinks" } + OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :coverage_store => nil, :name => nil, :title => nil, :abstract => nil, :metadata_links => [] } define_attribute_methods OBJ_ATTRIBUTES.keys update_attribute_accessors OBJ_ATTRIBUTES @@route = "workspaces/%s/coveragestores/%s/coverages" @@ -31,11 +31,24 @@ def message builder = Nokogiri::XML::Builder.new do |xml| xml.coverage { xml.name @name - xml.title @title + xml.title @title + unless new? + xml.nativeName @name + xml.abstract @abtract if abstract_changed? + xml.metadataLinks { + @metadata_links.each{ |m| + xml.metadataLink { + xml.type_ m['type'] + xml.metadataType m['metadataType'] + xml.content m['content'] + } + } + } if metadata_links_changed? + end } end @message = builder.doc.to_xml end @@ -73,12 +86,36 @@ 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').to_s, - "title" => doc.at_xpath('//title').to_s, - "supportedFormats" => doc.xpath('//supportedFormats/string').collect{ |t| t.to_s } + "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 }, + "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.strip + } + } }.freeze h end