Class: ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SpatialColumn

Inherits:
ConnectionAdapters::MySQL::Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) ⇒ SpatialColumn

Returns a new instance of SpatialColumn.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 5

def initialize(name, default,  = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil)
  @geometric_type = nil
  if sql_type =~ /geometry|point|linestring|polygon/i
    build_from_sql_type(.sql_type)
  elsif .sql_type =~ /geometry|point|linestring|polygon/i
    # A geometry column with no geometry_columns entry.
    # @geometric_type = geo_type_from_sql_type(sql_type)
    build_from_sql_type(.sql_type)
  end
  super(name, default, , null, table_name, default_function, collation)
  @comment = comment
  if spatial?
    if @srid
      @limit = { type: @geometric_type.type_name.underscore }
      @limit[:srid] = @srid if @srid
    end
  end
end

Instance Attribute Details

#geometric_typeObject (readonly)

Returns the value of attribute geometric_type.



24
25
26
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 24

def geometric_type
  @geometric_type
end

#sridObject (readonly)

Returns the value of attribute srid.



24
25
26
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 24

def srid
  @srid
end

Instance Method Details

#geographicObject Also known as: geographic?



34
35
36
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 34

def geographic
  false
end

#has_mObject Also known as: has_m?



30
31
32
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 30

def has_m
  false
end

#has_zObject Also known as: has_z?



26
27
28
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 26

def has_z
  false
end

#klassObject



50
51
52
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 50

def klass
  type == :spatial ? RGeo::Feature::Geometry : super
end

#limitObject



42
43
44
45
46
47
48
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 42

def limit
  if spatial?
    @limit
  else
    super
  end
end

#multi?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 58

def multi?
  /^(geometrycollection|multi)/i.match?(sql_type)
end

#spatial?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 54

def spatial?
  !@geometric_type.nil?
end