cocina_display 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 314d08be365121515add19014c2c3d6593d1016fd3ce5e53928c991ce209b64a
4
- data.tar.gz: 31cc7393ccaf6285f7e1df378a22d3347c23d4853a0eb34bfe3402b3d5818045
3
+ metadata.gz: f74e1deeabaf3c4c9535967c1903bc6b393aa365a5ef9d917a977db60538397b
4
+ data.tar.gz: 2b56b34bbabd4f7c8d0fe94d668fd1753de48009888c1f18eece1c429dafe3c8
5
5
  SHA512:
6
- metadata.gz: ae4df0a3875374c472f8360110281e519e8bd423f68bfb29f61e618cf8f39e4a99182273ae6d61b77373cd298d827110a50acb3d7c9fafc1e80fe5f996576e74
7
- data.tar.gz: af43069ebf9d00828814b9d313ed1f670beb94591cc2a15d28fcaa24bd72773cca3b48b23429fd7a1e195b65e3ea258c073e56e9382722b2bd45aa8244374b9a
6
+ metadata.gz: 74c89bf0c7e40e8dcdcf4c60be91002c8e563bd4a5a796e17a255cb739fcdd3088788bc31d5cd62a6b0e1af22a0155fd90ab6db4ffcca1e2302d770dae4ab764
7
+ data.tar.gz: 0e47b6097c557bc1c73d360a5fc37d55aa7f58db6173f4f0fb8851c493f2095e9181355c41b984522066a6d7649d97827a707315708239ebf958cdcd4455baee
@@ -39,6 +39,14 @@ module CocinaDisplay
39
39
  coordinate_objects.map(&:as_point).uniq
40
40
  end
41
41
 
42
+ # All valid coordinate data formatted as bounding boxes.
43
+ # Format is [[min_lat, min_long], [max_lat, max_long]].
44
+ # @note Points are not included since they can't be represented as a box.
45
+ # @return [Array<Array<Array<Float>>>]
46
+ def coordinates_as_bbox
47
+ coordinate_objects.map(&:as_bbox).compact.uniq
48
+ end
49
+
42
50
  # Identifiers assigned by geonames.org for places related to the object.
43
51
  # @return [Array<String>]
44
52
  # @example ["6252001", "5368361"]
@@ -253,7 +253,7 @@ module CocinaDisplay
253
253
  # @return [String]
254
254
  def sort_key
255
255
  # Even if not parsed, we might need to sort it for display later
256
- return "" unless parsed_date?
256
+ return "" unless parsed_date? && known?
257
257
 
258
258
  # Use the start of an interval for sorting
259
259
  sort_date = date.is_a?(EDTF::Interval) ? date.from : date
@@ -130,6 +130,13 @@ module CocinaDisplay
130
130
  nil
131
131
  end
132
132
 
133
+ # Format as a bounding box.
134
+ # @note This is impossible for a single point; we always return nil.
135
+ # @return [nil]
136
+ def as_bbox
137
+ nil
138
+ end
139
+
133
140
  # Format as a space-separated x y (longitude latitude) pair.
134
141
  # @note Limits decimals to 6 places.
135
142
  # @example "-118.2437 34.0522"
@@ -197,7 +204,7 @@ module CocinaDisplay
197
204
 
198
205
  # Format using the CQL ENVELOPE representation.
199
206
  # @note Limits decimals to 6 places.
200
- # @example "ENVELOPE(-118.243700, -117.952200, 34.199600, 34.052200)"
207
+ # @example "ENVELOPE(-118.2437, -117.9522, 34.1996, 34.0522)"
201
208
  # @return [String]
202
209
  def as_envelope
203
210
  "ENVELOPE(%.6f, %.6f, %.6f, %.6f)" % [
@@ -215,6 +222,14 @@ module CocinaDisplay
215
222
  center = min_point.endpoint(distance / 2, azimuth)
216
223
  "%.6f %.6f" % [center.lng, center.lat]
217
224
  end
225
+
226
+ # Format the bounding box as an array of two coordinate pairs [[S, W], [N, E]].
227
+ # @note Limits decimals to 6 places.
228
+ # @return [Array<Array<Float>>]
229
+ # @example [[-118.2437, 34.0522], [-117.9522, 34.1996]]
230
+ def as_bbox
231
+ [[min_point.lat, min_point.lng], [max_point.lat, max_point.lng]]
232
+ end
218
233
  end
219
234
 
220
235
  # Base class for parsers that convert strings into Coordinates objects.
@@ -2,8 +2,8 @@ module CocinaDisplay
2
2
  module Subjects
3
3
  # A Subject in Cocina structured data, possibly in multiple languages.
4
4
  class Subject < Parallel::Parallel
5
- # String representation uses the main parallel value.
6
- delegate :to_s, to: :main_value
5
+ # String representation and parts reference the main parallel value.
6
+ delegate :to_s, :delimiter, :subject_parts, :values, to: :main_value
7
7
 
8
8
  # Label used when displaying the Subject.
9
9
  # @return [String]
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "2.3.1" # :nodoc:
5
+ VERSION = "2.4.0" # :nodoc:
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Budak
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-04-20 00:00:00.000000000 Z
10
+ date: 2026-04-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: janeway-jsonpath