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.

Instance Method Summary collapse

Instance Method Details

#st_area(units = nil) ⇒ Object

– Surface functions ++


198
199
200
201
202
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 198

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


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

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

#st_astextObject


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

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

#st_boundaryObject


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

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

#st_buffer(distance, units = nil) ⇒ Object


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

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


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

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

#st_contains(rhs) ⇒ Object


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

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

#st_convexhullObject


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

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

#st_crosses(rhs) ⇒ Object


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

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

#st_difference(rhs) ⇒ Object


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

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

#st_dimensionObject

– Geometry functions ++


26
27
28
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 26

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

#st_disjoint(rhs) ⇒ Object


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

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

#st_distance(rhs, units = nil) ⇒ Object


100
101
102
103
104
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 100

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


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

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

#st_envelopeObject


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

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

#st_equals(rhs) ⇒ Object


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

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

#st_exteriorringObject

– Polygon functions ++


216
217
218
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 216

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

#st_function(function, *args) ⇒ Object

– Generic functions ++


17
18
19
20
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 17

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


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

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

#st_geometrytypeObject


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

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

#st_interiorringn(n) ⇒ Object


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

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

#st_intersection(rhs) ⇒ Object


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

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

#st_intersects(rhs) ⇒ Object


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

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

#st_isclosedObject


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

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

#st_isemptyObject


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

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

#st_isringObject


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

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

#st_issimpleObject


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

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

#st_length(units = nil) ⇒ Object


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

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


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

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

#st_numgeometriesObject

– GeometryCollection functions ++


234
235
236
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 234

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

#st_numinteriorringsObject


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

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 ++


185
186
187
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 185

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

#st_overlaps(rhs) ⇒ Object


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

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

#st_pointn(n) ⇒ Object


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

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

#st_pointonsurfaceObject


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

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

#st_relate(rhs, matrix = nil) ⇒ Object


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

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


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

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

#st_startpointObject

– Curve functions ++


158
159
160
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 158

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

#st_symdifference(rhs) ⇒ Object


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

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

#st_touches(rhs) ⇒ Object


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

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

#st_union(rhs) ⇒ Object


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

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

#st_within(rhs) ⇒ Object


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

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

#st_xObject

– Point functions ++


137
138
139
# File 'lib/rgeo/active_record/spatial_expressions.rb', line 137

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

#st_yObject


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

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

#st_zObject


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

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