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.



125
126
127
# File 'lib/activerecord-spatial/spatial_columns.rb', line 125

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

#geography_column_by_name(name) ⇒ Object

Grabs a geography column based on name.



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

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.



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

def geography_columns; end

#geography_columns!Object

Force a reload of available geography columns.



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

def geography_columns!; end

#geometry_column_by_name(name) ⇒ Object

Grabs a geometry column based on name.



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

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.



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

def geometry_columns; end

#geometry_columns!Object

Force a reload of available geometry columns.



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

def geometry_columns!; end

#spatial_column_by_name(name) ⇒ Object

Grabs a spatial column based on name.



84
85
86
# File 'lib/activerecord-spatial/spatial_columns.rb', line 84

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

#spatial_columnsObject

Returns both the geometry and geography columns for a table.



74
75
76
# File 'lib/activerecord-spatial/spatial_columns.rb', line 74

def spatial_columns
  geometry_columns + geography_columns
end

#spatial_columns!Object

Reloads both the geometry and geography columns for a table.



79
80
81
# File 'lib/activerecord-spatial/spatial_columns.rb', line 79

def spatial_columns!
  geometry_columns! + geography_columns!
end

#spatial_function(*args) ⇒ Object

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



45
46
47
# File 'lib/activerecord-spatial/spatial_columns.rb', line 45

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

#srid_for(column_name) ⇒ Object

Quickly grab the SRID for a geometry column.



119
120
121
122
# File 'lib/activerecord-spatial/spatial_columns.rb', line 119

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