Module: ActiveRecordSpatial::SpatialColumns::ClassMethods

Defined in:
lib/activerecord-spatial/spatial_columns.rb

Instance Method Summary collapse

Instance Method Details

#coord_dimension_for(column_name) ⇒ Object

Quickly grab the number of dimensions for a geometry column.



128
129
130
# File 'lib/activerecord-spatial/spatial_columns.rb', line 128

def coord_dimension_for(column_name)
  self.spatial_column_by_name(column_name).coord_dimension
end

#geography_column_by_name(name) ⇒ Object

Grabs a geography column based on name.



73
# File 'lib/activerecord-spatial/spatial_columns.rb', line 73

def geography_column_by_name(name); end

#geography_columnsObject

Returns an Array of available geography columns in the table. These are PostgreSQLColumns with values set for the srid and coord_dimensions properties.



61
# File 'lib/activerecord-spatial/spatial_columns.rb', line 61

def geography_columns; end

#geography_columns!Object

Force a reload of available geography columns.



67
# File 'lib/activerecord-spatial/spatial_columns.rb', line 67

def geography_columns!; end

#geometry_column_by_name(name) ⇒ Object

Grabs a geometry column based on name.



70
# File 'lib/activerecord-spatial/spatial_columns.rb', line 70

def geometry_column_by_name(name); end

#geometry_columnsObject

Returns an Array of available geometry columns in the table. These are PostgreSQLColumns with values set for the srid and coord_dimensions properties.



56
# File 'lib/activerecord-spatial/spatial_columns.rb', line 56

def geometry_columns; end

#geometry_columns!Object

Force a reload of available geometry columns.



64
# File 'lib/activerecord-spatial/spatial_columns.rb', line 64

def geometry_columns!; end

#spatial_column_by_name(name) ⇒ Object

Grabs a spatial column based on name.



86
87
88
# File 'lib/activerecord-spatial/spatial_columns.rb', line 86

def spatial_column_by_name(name)
  self.geometry_column_by_name(name) || self.geography_column_by_name(name)
end

#spatial_columnsObject

Returns both the geometry and geography columns for a table.



76
77
78
# File 'lib/activerecord-spatial/spatial_columns.rb', line 76

def spatial_columns
  self.geometry_columns + self.geography_columns
end

#spatial_columns!Object

Reloads both the geometry and geography columns for a table.



81
82
83
# File 'lib/activerecord-spatial/spatial_columns.rb', line 81

def spatial_columns!
  self.geometry_columns! + self.geography_columns!
end

#spatial_function(*args) ⇒ Object

Build call to ActiveRecordSpatial::SpatialFunction.build! that helps you create spatial function calls.



47
48
49
# File 'lib/activerecord-spatial/spatial_columns.rb', line 47

def spatial_function(*args)
  SpatialFunction.build!(self, *args)
end

#srid_for(column_name) ⇒ Object

Quickly grab the SRID for a geometry column.



122
123
124
125
# File 'lib/activerecord-spatial/spatial_columns.rb', line 122

def srid_for(column_name)
  column = self.spatial_column_by_name(column_name)
  column.try(:srid) || ActiveRecordSpatial::UNKNOWN_SRID
end