Module: RGeo::ActiveRecord::SpatialExpressions

Included in:
SpatialConstantNode, SpatialNamedFunction
Defined in:
lib/rgeo/active_record/spatial_expressions.rb

Overview

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

These functions require Arel 2.1 or later.

Instance Method Summary collapse

Instance Method Details

#st_area(units_ = nil) ⇒ Object

– Surface functions ++



202
203
204
205
206
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 202

def st_area(units_=nil)
  args_ = [self]
  args_ << units.to_s if units_
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_StartPoint', args_, [false, true, false])
end

#st_asbinaryObject



42
43
44
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 42

def st_asbinary
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_AsBinary', [self], [false, true])
end

#st_astextObject



38
39
40
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 38

def st_astext
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_AsText', [self], [false, true])
end

#st_boundaryObject



58
59
60
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 58

def st_boundary
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Boundary', [self], [true, true])
end

#st_buffer(distance_, units_ = nil) ⇒ Object



126
127
128
129
130
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 126

def st_buffer(distance_, units_=nil)
  args_ = [self, distance_.to_f]
  args_ << units.to_s if units_
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Buffer', args_, [true, true, false])
end

#st_centroidObject



208
209
210
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 208

def st_centroid
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Centroid', [self], [true, true])
end

#st_contains(rhs_) ⇒ Object



90
91
92
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 90

def st_contains(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Contains', [self, rhs_], [false, true, true])
end

#st_convexhullObject



132
133
134
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 132

def st_convexhull
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_ConvexHull', [self], [true, true])
end

#st_crosses(rhs_) ⇒ Object



82
83
84
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 82

def st_crosses(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Crosses', [self, rhs_], [false, true, true])
end

#st_difference(rhs_) ⇒ Object



114
115
116
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 114

def st_difference(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Difference', [self, rhs_], [true, true, true])
end

#st_dimensionObject

– Geometry functions ++



30
31
32
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 30

def st_dimension
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Dimension', [self], [false, true])
end

#st_disjoint(rhs_) ⇒ Object



70
71
72
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 70

def st_disjoint(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Disjoint', [self, rhs_], [false, true, true])
end

#st_distance(rhs_, units_ = nil) ⇒ Object



104
105
106
107
108
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 104

def st_distance(rhs_, units_=nil)
  args_ = [self, rhs_]
  args_ << units.to_s if units_
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Distance', args_, [false, true, true, false])
end

#st_endpointObject



166
167
168
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 166

def st_endpoint
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_EndPoint', [self], [true, true])
end

#st_envelopeObject



62
63
64
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 62

def st_envelope
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Envelope', [self], [true, true])
end

#st_equals(rhs_) ⇒ Object



66
67
68
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 66

def st_equals(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Equals', [self, rhs_], [false, true, true])
end

#st_exteriorringObject

– Polygon functions ++



220
221
222
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 220

def st_exteriorring
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_ExteriorRing', [self], [true, true])
end

#st_function(function_, *args_) ⇒ Object

– Generic functions ++



21
22
23
24
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 21

def st_function(function_, *args_)
  spatial_info_ = args_.last.is_a?(::Array) ? args_.pop : []
  ::RGeo::ActiveRecord::SpatialNamedFunction.new(function_, [self] + args_, spatial_info_)
end

#st_geometryn(n_) ⇒ Object



242
243
244
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 242

def st_geometryn(n_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_GeometryN', [self, n_.to_i], [true, true, false])
end

#st_geometrytypeObject



34
35
36
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 34

def st_geometrytype
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_GeometryType', [self], [false, true])
end

#st_interiorringn(n_) ⇒ Object



230
231
232
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 230

def st_interiorringn(n_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_InteriorRingN', [self, n_.to_i], [true, true, false])
end

#st_intersection(rhs_) ⇒ Object



110
111
112
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 110

def st_intersection(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Intersection', [self, rhs_], [true, true, true])
end

#st_intersects(rhs_) ⇒ Object



74
75
76
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 74

def st_intersects(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Intersects', [self, rhs_], [false, true, true])
end

#st_isclosedObject



170
171
172
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 170

def st_isclosed
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsClosed', [self], [false, true])
end

#st_isemptyObject



50
51
52
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 50

def st_isempty
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsEmpty', [self], [false, true])
end

#st_isringObject



174
175
176
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 174

def st_isring
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsRing', [self], [false, true])
end

#st_issimpleObject



54
55
56
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 54

def st_issimple
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_IsSimple', [self], [false, true])
end

#st_length(units_ = nil) ⇒ Object



178
179
180
181
182
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 178

def st_length(units_=nil)
  args_ = [self]
  args_ << units.to_s if units_
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Length', args_, [false, true, false])
end

#st_mObject



153
154
155
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 153

def st_m
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_M', [self], [false, true])
end

#st_numgeometriesObject

– GeometryCollection functions ++



238
239
240
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 238

def st_numgeometries
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumGeometries', [self], [false, true])
end

#st_numinteriorringsObject



224
225
226
227
228
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 224

def st_numinteriorrings
  # Note: the name difference is intentional. The standard
  # names this function incorrectly.
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumInteriorRing', [self], [false, true])
end

#st_numpointsObject

– LineString functions ++



189
190
191
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 189

def st_numpoints
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_NumPoints', [self], [false, true])
end

#st_overlaps(rhs_) ⇒ Object



94
95
96
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 94

def st_overlaps(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Overlaps', [self, rhs_], [false, true, true])
end

#st_pointn(n_) ⇒ Object



193
194
195
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 193

def st_pointn(n_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_PointN', [self, n_.to_i], [true, true, false])
end

#st_pointonsurfaceObject



212
213
214
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 212

def st_pointonsurface
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_PointOnSurface', [self], [true, true])
end

#st_relate(rhs_, matrix_ = nil) ⇒ Object



98
99
100
101
102
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 98

def st_relate(rhs_, matrix_=nil)
  args_ = [self, rhs_]
  args_ << matrix.to_s if matrix_
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Relate', args_, [false, true, true, false])
end

#st_sridObject



46
47
48
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 46

def st_srid
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_SRID', [self], [false, true])
end

#st_startpointObject

– Curve functions ++



162
163
164
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 162

def st_startpoint
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_StartPoint', [self], [true, true])
end

#st_symdifference(rhs_) ⇒ Object



122
123
124
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 122

def st_symdifference(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_SymDifference', [self, rhs_], [true, true, true])
end

#st_touches(rhs_) ⇒ Object



78
79
80
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 78

def st_touches(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Touches', [self, rhs_], [false, true, true])
end

#st_union(rhs_) ⇒ Object



118
119
120
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 118

def st_union(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Union', [self, rhs_], [true, true, true])
end

#st_within(rhs_) ⇒ Object



86
87
88
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 86

def st_within(rhs_)
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Within', [self, rhs_], [false, true, true])
end

#st_xObject

– Point functions ++



141
142
143
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 141

def st_x
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_X', [self], [false, true])
end

#st_yObject



145
146
147
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 145

def st_y
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Y', [self], [false, true])
end

#st_zObject



149
150
151
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 149

def st_z
  ::RGeo::ActiveRecord::SpatialNamedFunction.new('ST_Z', [self], [false, true])
end