Module: ActiveRecord::ConnectionAdapters::PostGIS::ColumnDefinitionUtils

Defined in:
lib/active_record/connection_adapters/postgis/spatial_table_definition.rb

Class Method Summary collapse

Class Method Details

.default_srid(options) ⇒ Object


47
48
49
# File 'lib/active_record/connection_adapters/postgis/spatial_table_definition.rb', line 47

def default_srid(options)
  options[:geographic] ? 4326 : PostGISAdapter::DEFAULT_SRID
end

.geo_type(type = "GEOMETRY") ⇒ Object


32
33
34
35
36
37
# File 'lib/active_record/connection_adapters/postgis/spatial_table_definition.rb', line 32

def geo_type(type = "GEOMETRY")
  g_type = type.to_s.delete("_").upcase
  return "POINT" if g_type == "STPOINT"
  return "POLYGON" if g_type == "STPOLYGON"
  g_type
end

.limit_from_options(type, options = {}) ⇒ Object


39
40
41
42
43
44
45
# File 'lib/active_record/connection_adapters/postgis/spatial_table_definition.rb', line 39

def limit_from_options(type, options = {})
  spatial_type = geo_type(type)
  spatial_type << "Z" if options[:has_z]
  spatial_type << "M" if options[:has_m]
  spatial_type << ",#{options[:srid] || default_srid(options)}"
  spatial_type
end