Skip to content

Commit

Permalink
Make Schema org output also support multiple geolocation polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Mar 24, 2021
1 parent ec27b37 commit 69c6ac5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,11 @@ def to_schema_org_spatial_coverage(geo_location)
"@type" => "GeoShape",
"address" => gl["geoLocationPlace"],
"polygon" => Array.wrap(gl.dig("geoLocationPolygon")).map do |glp|
[glp.dig("polygonPoint", "pointLongitude"), glp.dig("polygonPoint", "pointLatitude")].compact
end.compact }
Array.wrap(glp).map do |glpp|
[glpp.dig("polygonPoint", "pointLongitude"), glpp.dig("polygonPoint", "pointLatitude")].compact
end.compact
end.compact.presence,
}
}
end

Expand Down
6 changes: 3 additions & 3 deletions spec/writers/schema_org_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
it "author is organization" do
input = fixture_path + 'gtex.xml'
url = "https://ors.datacite.org/doi:/10.25491/9hx8-ke93"
content_url = "https://storage.googleapis.com/gtex_analysis_v7/single_tissue_eqtl_data/GTEx_Analysis_v7_eQTL_expression_matrices.tar.gz"
content_url = "https://storage.googleapis.com/gtex_analysis_v7/single_tissue_eqtl_data/GTEx_Analysis_v7_eQTL_expression_matrices.tar.gz"
subject = Bolognese::Metadata.new(input: input, url: url, content_url: content_url, from: "datacite")
json = JSON.parse(subject.schema_org)
expect(json["@id"]).to eq("https://doi.org/10.25491/9hx8-ke93")
Expand Down Expand Up @@ -281,8 +281,8 @@
expect(json["name"]).to eq("Meteo measurements at the Sand Motor")
expect(json["author"]).to eq("@type"=>"Person", "familyName"=>"Den Heijer", "givenName"=>"C", "name"=>"C Den Heijer")
expect(json["includedInDataCatalog"]).to be_nil
expect(json["spatialCoverage"].dig("geo", "polygon").length).to eq(34)
expect(json["spatialCoverage"].dig("geo", "polygon").first).to eq(["4.1738852605822", "52.03913926329928"])
expect(json["spatialCoverage"].dig("geo", "polygon")[0].length).to eq(34)
expect(json["spatialCoverage"].dig("geo", "polygon")[0].first).to eq(["4.1738852605822", "52.03913926329928"])
end

it "from schema_org gtex" do
Expand Down

0 comments on commit 69c6ac5

Please sign in to comment.