Module: RDBr::Web::SpatialValueHelpers

Included in:
Helpers
Defined in:
lib/rdbr/web/spatial_value_helpers.rb

Constant Summary collapse

SPATIAL_TYPES =
%i[box circle geography geometry line lseg path point polygon].freeze
GEOMETRY_NAMES =
{
  'geometrycollection' => 'Geometry collection', 'linestring' => 'Line string',
  'multilinestring' => 'Multi-line string', 'multipoint' => 'Multi-point',
  'multipolygon' => 'Multi-polygon', 'point' => 'Point', 'polygon' => 'Polygon'
}.freeze

Instance Method Summary collapse

Instance Method Details

#render_spatial_value(column, value) ⇒ Object



18
19
20
21
# File 'lib/rdbr/web/spatial_value_helpers.rb', line 18

def render_spatial_value(column, value)
  text, summary = spatial_presentation(column, value)
  render_deferred_value(text, qualifier: 'spatial', summary: summary)
end

#spatial_column?(column) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/rdbr/web/spatial_value_helpers.rb', line 13

def spatial_column?(column)
  type = column.logical_type.to_s.downcase.to_sym
  SPATIAL_TYPES.include?(type) || column.sql_type.to_s.match?(spatial_type_pattern)
end