Class: CocinaDisplay::Geospatial::Point
- Inherits:
-
Coordinates
- Object
- Coordinates
- CocinaDisplay::Geospatial::Point
- Defined in:
- lib/cocina_display/geospatial.rb
Overview
A single geospatial point with latitude and longitude.
Instance Attribute Summary collapse
-
#point ⇒ Object
readonly
Returns the value of attribute point.
Class Method Summary collapse
-
.from_coords(lat:, lng:) ⇒ Point?
Construct a Point from latitude and longitude string values.
Instance Method Summary collapse
-
#as_bbox ⇒ nil
Format as a bounding box.
-
#as_envelope ⇒ nil
Format using the CQL ENVELOPE representation.
-
#as_point ⇒ String
Format as a space-separated x y (longitude latitude) pair.
-
#as_wkt ⇒ String
Format using the Well-Known Text (WKT) representation.
-
#initialize(point) ⇒ Point
constructor
Construct a Point from a single Geo::Coord point.
-
#to_s ⇒ String
Format for display in DMS format, adapted from ISO 6709 standard.
Methods inherited from Coordinates
from_cocina, from_structured_values, parse
Constructor Details
#initialize(point) ⇒ Point
Construct a Point from a single Geo::Coord point.
136 137 138 |
# File 'lib/cocina_display/geospatial.rb', line 136 def initialize(point) @point = point end |
Instance Attribute Details
#point ⇒ Object (readonly)
Returns the value of attribute point.
121 122 123 |
# File 'lib/cocina_display/geospatial.rb', line 121 def point @point end |
Class Method Details
.from_coords(lat:, lng:) ⇒ Point?
Construct a Point from latitude and longitude string values.
127 128 129 130 131 132 |
# File 'lib/cocina_display/geospatial.rb', line 127 def self.from_coords(lat:, lng:) point = Geo::Coord.parse("#{lat}, #{lng}") return unless point new(point) end |
Instance Method Details
#as_bbox ⇒ nil
This is impossible for a single point; we always return nil.
Format as a bounding box.
168 169 170 |
# File 'lib/cocina_display/geospatial.rb', line 168 def as_bbox nil end |
#as_envelope ⇒ nil
This is impossible for a single point; we always return nil.
Format using the CQL ENVELOPE representation.
161 162 163 |
# File 'lib/cocina_display/geospatial.rb', line 161 def as_envelope nil end |
#as_point ⇒ String
Limits decimals to 6 places.
Format as a space-separated x y (longitude latitude) pair.
176 177 178 |
# File 'lib/cocina_display/geospatial.rb', line 176 def as_point "%.6f %.6f" % [point.lng, point.lat] end |
#as_wkt ⇒ String
Limits decimals to 6 places.
Format using the Well-Known Text (WKT) representation.
154 155 156 |
# File 'lib/cocina_display/geospatial.rb', line 154 def as_wkt "POINT(%.6f %.6f)" % [point.lng, point.lat] end |
#to_s ⇒ String
This format adapts the "Annex D" human representation style.
Format for display in DMS format, adapted from ISO 6709 standard.
145 146 147 |
# File 'lib/cocina_display/geospatial.rb', line 145 def to_s format_point(point).join(" ") end |