module RGeo::ActiveRecord::SpatialExpressions

A set of spatial expression builders. These methods can be chained off other spatial expressions to form complex expressions.

Public Instance Methods

st_area(units = nil) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 196
def st_area(units = nil)
  args = [self]
  args << units.to_s if units
  SpatialNamedFunction.new("ST_Area", args, [false, true, false])
end
st_asbinary() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 40
def st_asbinary
  SpatialNamedFunction.new("ST_AsBinary", [self], [false, true])
end
st_astext() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 36
def st_astext
  SpatialNamedFunction.new("ST_AsText", [self], [false, true])
end
st_boundary() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 56
def st_boundary
  SpatialNamedFunction.new("ST_Boundary", [self], [true, true])
end
st_buffer(distance, units = nil) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 124
def st_buffer(distance, units = nil)
  args = [self, distance.to_f]
  args << units.to_s if units
  SpatialNamedFunction.new("ST_Buffer", args, [true, true, false])
end
st_centroid() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 202
def st_centroid
  SpatialNamedFunction.new("ST_Centroid", [self], [true, true])
end
st_contains(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 88
def st_contains(rhs)
  SpatialNamedFunction.new("ST_Contains", [self, rhs], [false, true, true])
end
st_convexhull() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 130
def st_convexhull
  SpatialNamedFunction.new("ST_ConvexHull", [self], [true, true])
end
st_crosses(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 80
def st_crosses(rhs)
  SpatialNamedFunction.new("ST_Crosses", [self, rhs], [false, true, true])
end
st_difference(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 112
def st_difference(rhs)
  SpatialNamedFunction.new("ST_Difference", [self, rhs], [true, true, true])
end
st_dimension() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 28
def st_dimension
  SpatialNamedFunction.new("ST_Dimension", [self], [false, true])
end
st_disjoint(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 68
def st_disjoint(rhs)
  SpatialNamedFunction.new("ST_Disjoint", [self, rhs], [false, true, true])
end
st_distance(rhs, units = nil) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 102
def st_distance(rhs, units = nil)
  args = [self, rhs]
  args << units.to_s if units
  SpatialNamedFunction.new("ST_Distance", args, [false, true, true, false])
end
st_endpoint() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 162
def st_endpoint
  SpatialNamedFunction.new("ST_EndPoint", [self], [true, true])
end
st_envelope() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 60
def st_envelope
  SpatialNamedFunction.new("ST_Envelope", [self], [true, true])
end
st_equals(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 64
def st_equals(rhs)
  SpatialNamedFunction.new("ST_Equals", [self, rhs], [false, true, true])
end
st_exteriorring() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 214
def st_exteriorring
  SpatialNamedFunction.new("ST_ExteriorRing", [self], [true, true])
end
st_function(function, *args) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 19
def st_function(function, *args)
  spatial_info = args.last.is_a?(::Array) ? args.pop : []
  SpatialNamedFunction.new(function, [self] + args, spatial_info)
end
st_geometryn(n) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 236
def st_geometryn(n)
  SpatialNamedFunction.new("ST_GeometryN", [self, n.to_i], [true, true, false])
end
st_geometrytype() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 32
def st_geometrytype
  SpatialNamedFunction.new("ST_GeometryType", [self], [false, true])
end
st_interiorringn(n) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 224
def st_interiorringn(n)
  SpatialNamedFunction.new("ST_InteriorRingN", [self, n.to_i], [true, true, false])
end
st_intersection(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 108
def st_intersection(rhs)
  SpatialNamedFunction.new("ST_Intersection", [self, rhs], [true, true, true])
end
st_intersects(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 72
def st_intersects(rhs)
  SpatialNamedFunction.new("ST_Intersects", [self, rhs], [false, true, true])
end
st_isclosed() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 166
def st_isclosed
  SpatialNamedFunction.new("ST_IsClosed", [self], [false, true])
end
st_isempty() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 48
def st_isempty
  SpatialNamedFunction.new("ST_IsEmpty", [self], [false, true])
end
st_isring() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 170
def st_isring
  SpatialNamedFunction.new("ST_IsRing", [self], [false, true])
end
st_issimple() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 52
def st_issimple
  SpatialNamedFunction.new("ST_IsSimple", [self], [false, true])
end
st_length(units = nil) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 174
def st_length(units = nil)
  args = [self]
  args << units.to_s if units
  SpatialNamedFunction.new("ST_Length", args, [false, true, false])
end
st_m() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 150
def st_m
  SpatialNamedFunction.new("ST_M", [self], [false, true])
end
st_numgeometries() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 232
def st_numgeometries
  SpatialNamedFunction.new("ST_NumGeometries", [self], [false, true])
end
st_numinteriorrings() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 218
def st_numinteriorrings
  # Note: the name difference is intentional. The standard
  # names this function incorrectly.
  SpatialNamedFunction.new("ST_NumInteriorRing", [self], [false, true])
end
st_numpoints() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 184
def st_numpoints
  SpatialNamedFunction.new("ST_NumPoints", [self], [false, true])
end
st_overlaps(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 92
def st_overlaps(rhs)
  SpatialNamedFunction.new("ST_Overlaps", [self, rhs], [false, true, true])
end
st_pointn(n) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 188
def st_pointn(n)
  SpatialNamedFunction.new("ST_PointN", [self, n.to_i], [true, true, false])
end
st_pointonsurface() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 206
def st_pointonsurface
  SpatialNamedFunction.new("ST_PointOnSurface", [self], [true, true])
end
st_relate(rhs, matrix = nil) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 96
def st_relate(rhs, matrix = nil)
  args = [self, rhs]
  args << matrix.to_s if matrix
  SpatialNamedFunction.new("ST_Relate", args, [false, true, true, false])
end
st_srid() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 44
def st_srid
  SpatialNamedFunction.new("ST_SRID", [self], [false, true])
end
st_startpoint() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 158
def st_startpoint
  SpatialNamedFunction.new("ST_StartPoint", [self], [true, true])
end
st_symdifference(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 120
def st_symdifference(rhs)
  SpatialNamedFunction.new("ST_SymDifference", [self, rhs], [true, true, true])
end
st_touches(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 76
def st_touches(rhs)
  SpatialNamedFunction.new("ST_Touches", [self, rhs], [false, true, true])
end
st_union(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 116
def st_union(rhs)
  SpatialNamedFunction.new("ST_Union", [self, rhs], [true, true, true])
end
st_within(rhs) click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 84
def st_within(rhs)
  SpatialNamedFunction.new("ST_Within", [self, rhs], [false, true, true])
end
st_x() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 138
def st_x
  SpatialNamedFunction.new("ST_X", [self], [false, true])
end
st_y() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 142
def st_y
  SpatialNamedFunction.new("ST_Y", [self], [false, true])
end
st_z() click to toggle source
# File lib/rgeo/active_record/spatial_expressions.rb, line 146
def st_z
  SpatialNamedFunction.new("ST_Z", [self], [false, true])
end