lib/geo_combine/geoblacklight.rb in geo_combine-0.2.0 vs lib/geo_combine/geoblacklight.rb in geo_combine-0.3.0
- old
+ new
@@ -43,11 +43,13 @@
##
# Validates a GeoBlacklight-Schema json document
# @return [Boolean]
def valid?
@schema ||= JSON.parse(open("https://raw.githubusercontent.com/geoblacklight/geoblacklight/#{GEOBLACKLIGHT_VERSION}/schema/geoblacklight-schema.json").read)
- JSON::Validator.validate!(@schema, to_json, fragment: '#/properties/layer') && dct_references_validate!
+ JSON::Validator.validate!(@schema, to_json, fragment: '#/properties/layer') &&
+ dct_references_validate! &&
+ spatial_validate!
end
##
# Validate dct_references_s
# @return [Boolean]
@@ -58,9 +60,13 @@
raise GeoCombine::Exceptions::InvalidDCTReferences, 'dct_references must be parsed to a Hash' unless ref.is_a?(Hash)
true
rescue JSON::ParserError => e
raise e, "Invalid JSON in dct_references_s: #{e.message}"
end
+ end
+
+ def spatial_validate!
+ GeoCombine::BoundingBox.from_envelope(metadata['solr_geom']).valid?
end
private
##