module RPClustering::RGeo::ActiveRecord::ArelTableSpatialExpressions

Spatial Expressions to be attached to Arel Table (DB tables)

Public Instance Methods

st_astext(g) click to toggle source

ST_AsText: www.postgis.org/docs/ST_AsText.html

Returns a string (WKT)

# File lib/rp_clustering-rgeo-activerecord/arel_table_spatial_expressions.rb, line 51
def st_astext(g)
  args = [g]

  ::RGeo::ActiveRecord::SpatialNamedFunction.new(
    'ST_AsText', args, [true, true]
  )

end
st_centroid(g) click to toggle source

ST_Centroid: www.postgis.org/docs/ST_Centroid.html

Implements postgis function variant:

geometry ST_Centroid(geometry g1);

Returns a geometry

# File lib/rp_clustering-rgeo-activerecord/arel_table_spatial_expressions.rb, line 68
def st_centroid(g)
  args = [g]

  ::RGeo::ActiveRecord::SpatialNamedFunction.new(
    'ST_Centroid', args, [true, true]
  )
end
st_collect(g1_array) click to toggle source

ST_Collect: www.postgis.org/docs/ST_Collect.html

Implements postgis function variant:

geometry ST_Collect(geometry[] g1_array);

This variant is an aggregate, it operates on rows of data.

Returns a geometry collection

# File lib/rp_clustering-rgeo-activerecord/arel_table_spatial_expressions.rb, line 38
def st_collect(g1_array)
  args = [g1_array]

  ::RGeo::ActiveRecord::SpatialNamedFunction.new(
    'ST_Collect', args, [true, true]
  )

end
st_minimumboundingcircle(g, num_segs=nil) click to toggle source

ST_MinimumBoundingCircle: www.postgis.org/docs/ST_MinimumBoundingCircle.html

Implements postgis function variant:

geometry ST_MinimumBoundingCircle(geometry geomA, integer num_segs_per_qt_circ=48);

Returns a geometry

# File lib/rp_clustering-rgeo-activerecord/arel_table_spatial_expressions.rb, line 84
def st_minimumboundingcircle(g, num_segs=nil)
  args = [g]
  spatial_flags = [true, true]

  if num_segs
    args << num_segs.to_s
    spatial_flags << false
  end

  ::RGeo::ActiveRecord::SpatialNamedFunction.new(
    'ST_MinimumBoundingCircle', args, spatial_flags
  )
end
st_snaptogrid(geom_a, grid_size) click to toggle source

ST_SnapToGrid: www.postgis.org/docs/ST_SnapToGrid.html

Implements postgis function variant:

geometry ST_SnapToGrid(geometry geomA, float size);

Returns a geometry collection

# File lib/rp_clustering-rgeo-activerecord/arel_table_spatial_expressions.rb, line 19
def st_snaptogrid(geom_a, grid_size)
  args = [geom_a, grid_size.to_s]

  ::RGeo::ActiveRecord::SpatialNamedFunction.new(
    'ST_SnapToGrid', args, [true, true, false]
  )

end