Class: ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SpatialColumn
- Inherits:
-
ConnectionAdapters::MySQL::Column
- Object
- ConnectionAdapters::MySQL::Column
- ActiveRecord::ConnectionAdapters::Mysql2Rgeo::SpatialColumn
- Defined in:
- lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#geometric_type ⇒ Object
readonly
Returns the value of attribute geometric_type.
-
#srid ⇒ Object
readonly
Returns the value of attribute srid.
Instance Method Summary collapse
- #geographic ⇒ Object (also: #geographic?)
- #has_m ⇒ Object (also: #has_m?)
- #has_z ⇒ Object (also: #has_z?)
-
#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) ⇒ SpatialColumn
constructor
A new instance of SpatialColumn.
- #klass ⇒ Object
- #limit ⇒ Object
- #multi? ⇒ Boolean
- #spatial? ⇒ Boolean
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_type ⇒ Object (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 |
#srid ⇒ Object (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
#geographic ⇒ Object Also known as: geographic?
33 34 35 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 33 def geographic false end |
#has_m ⇒ Object 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_z ⇒ Object 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 |
#klass ⇒ Object
49 50 51 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 49 def klass type == :spatial ? RGeo::Feature::Geometry : super end |
#limit ⇒ Object
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
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
53 54 55 |
# File 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb', line 53 def spatial? !@geometric_type.nil? end |