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
# 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.



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

def geometric_type
  @geometric_type
end

#sridObject (readonly)

Returns the value of attribute srid.



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

def srid
  @srid
end

Instance Method Details

#geographicObject Also known as: geographic?



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

def geographic
  false
end

#has_mObject Also known as: has_m?



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

def has_m
  false
end

#has_zObject Also known as: has_z?



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

def has_z
  false
end

#klassObject



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

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

#limitObject



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

def limit
  if spatial?
    @limit
  else
    super
  end
end

#multi?Boolean

Returns:

  • (Boolean)


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

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

#spatial?Boolean

Returns:

  • (Boolean)


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

def spatial?
  !@geometric_type.nil?
end