Class: ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumn
- Inherits:
-
ConnectionAdapters::PostgreSQLColumn
- Object
- ConnectionAdapters::PostgreSQLColumn
- ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumn
- Defined in:
- lib/active_record/connection_adapters/postgis/spatial_column.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#geographic ⇒ Object
(also: #geographic?)
readonly
Returns the value of attribute geographic.
-
#geometric_type ⇒ Object
readonly
Returns the value of attribute geometric_type.
-
#has_m ⇒ Object
(also: #has_m?)
readonly
Returns the value of attribute has_m.
-
#has_z ⇒ Object
(also: #has_z?)
readonly
Returns the value of attribute has_z.
-
#srid ⇒ Object
readonly
Returns the value of attribute srid.
Instance Method Summary collapse
-
#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, cast_type = nil, opts = nil) ⇒ SpatialColumn
constructor
sql_type examples: “Geometry(Point,4326)” “Geography(Point,4326)” cast_type example classes: OID::Spatial OID::Integer.
- #limit ⇒ Object
- #spatial? ⇒ Boolean
Constructor Details
#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, cast_type = nil, opts = nil) ⇒ SpatialColumn
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 11 def initialize(name, default, = nil, null = true, table_name = nil, default_function = nil, collation = nil, cast_type = nil, opts = nil) @cast_type = cast_type @geographic = !!(.sql_type =~ /geography\(/i) if opts # This case comes from an entry in the geometry_columns table set_geometric_type_from_name(opts[:type]) @srid = opts[:srid].to_i @has_z = !!opts[:has_z] @has_m = !!opts[:has_m] elsif @geographic # Geographic type information is embedded in the SQL type @srid = 4326 @has_z = @has_m = false build_from_sql_type(.sql_type) elsif sql_type =~ /geography|geometry|point|linestring|polygon/i build_from_sql_type(.sql_type) elsif .sql_type =~ /geography|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) if spatial? if @srid @limit = { srid: @srid, type: to_type_name(geometric_type) } @limit[:has_z] = true if @has_z @limit[:has_m] = true if @has_m @limit[:geographic] = true if @geographic end end end |
Instance Attribute Details
#geographic ⇒ Object (readonly) Also known as: geographic?
Returns the value of attribute geographic.
43 44 45 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 43 def geographic @geographic end |
#geometric_type ⇒ Object (readonly)
Returns the value of attribute geometric_type.
43 44 45 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 43 def geometric_type @geometric_type end |
#has_m ⇒ Object (readonly) Also known as: has_m?
Returns the value of attribute has_m.
43 44 45 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 43 def has_m @has_m end |
#has_z ⇒ Object (readonly) Also known as: has_z?
Returns the value of attribute has_z.
43 44 45 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 43 def has_z @has_z end |
#srid ⇒ Object (readonly)
Returns the value of attribute srid.
43 44 45 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 43 def srid @srid end |
Instance Method Details
#limit ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 53 def limit if spatial? @limit else super end end |
#spatial? ⇒ Boolean
61 62 63 |
# File 'lib/active_record/connection_adapters/postgis/spatial_column.rb', line 61 def spatial? @cast_type.respond_to?(:spatial?) && @cast_type.spatial? end |