Module: RGeo::ActiveRecord

Defined in:
lib/rgeo/active_record.rb,
lib/rgeo/active_record/version.rb,
lib/rgeo/active_record/geometry_mixin.rb,
lib/rgeo/active_record/adapter_test_helper.rb,
lib/rgeo/active_record/ar_factory_settings.rb,
lib/rgeo/active_record/spatial_expressions.rb,
lib/rgeo/active_record/arel_spatial_queries.rb,
lib/rgeo/active_record/common_adapter_elements.rb

Overview

This module contains a set of ActiveRecord extensions for RGeo. Generally, you will not need to interact with the contents of this module directly, unless you are writing a spatial ActiveRecord connection adapter.

Defined Under Namespace

Modules: ActiveRecordBaseFactorySettings, AdapterTestHelper, GeoConnectionAdapters, GeoSchemaDumper, GeoTableDefinitions, GeometryMixin, SpatialExpressions, SpatialToSql Classes: RGeoFactorySettings, SpatialConstantNode, SpatialIndexDefinition, SpatialNamedFunction

Constant Summary collapse

VERSION =
'2.0.0'.freeze
DEFAULT_FACTORY_GENERATOR =

The default factory generator for ActiveRecord::Base.

::Proc.new do |config|
  if config.delete(:geographic)
    ::RGeo::Geographic.spherical_factory(config)
  else
    ::RGeo::Cartesian.preferred_factory(config)
  end
end
DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS =

Some default column constructors specifications for most spatial databases. Individual adapters may add to or override this list.

{
  spatial:             { :type => 'geometry' }.freeze,
  geometry:            {}.freeze,
  point:               {}.freeze,
  line_string:         {}.freeze,
  polygon:             {}.freeze,
  geometry_collection: {}.freeze,
  multi_line_string:   {}.freeze,
  multi_point:         {}.freeze,
  multi_polygon:       {}.freeze,
}.freeze

Class Method Summary collapse

Class Method Details

.geometric_type_from_name(name) ⇒ Object

Returns a feature type module given a string type.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rgeo/active_record/common_adapter_elements.rb', line 27

def self.geometric_type_from_name(name)
  case name.to_s
  when /^geometry/i then ::RGeo::Feature::Geometry
  when /^point/i then ::RGeo::Feature::Point
  when /^linestring/i then ::RGeo::Feature::LineString
  when /^polygon/i then ::RGeo::Feature::Polygon
  when /^geometrycollection/i then ::RGeo::Feature::GeometryCollection
  when /^multipoint/i then ::RGeo::Feature::MultiPoint
  when /^multilinestring/i then ::RGeo::Feature::MultiLineString
  when /^multipolygon/i then ::RGeo::Feature::MultiPolygon
  else nil
  end
end

.spatial_expressions_supported?Boolean

Returns true if spatial expressions (i.e. the methods in the SpatialExpressions module) are supported.

Returns:

  • (Boolean)


5
6
7
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 5

def self.spatial_expressions_supported?
  defined?(::Arel::Nodes::NamedFunction)
end